-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Add 'color' and 'size' to arguments #44856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
2f54813
3feaabc
68f2551
390fc86
865b7ac
1f30d45
543c64e
d1fd7bc
eda1fbc
1caf4dc
021aadd
5e94951
05a26c8
f7b833c
f99424e
abf377e
33c1ca5
f131fe4
e6ac538
c9d6043
757f292
53503ce
73e3fb1
e17db52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1582,7 +1582,7 @@ def pie(self, **kwargs): | |
raise ValueError("pie requires either y column or 'subplots=True'") | ||
return self(kind="pie", **kwargs) | ||
|
||
def scatter(self, x, y, s=None, c=None, **kwargs): | ||
def scatter(self, x, y, size=None, s=None, color=None, c=None, **kwargs): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this can be used as positional arguments and your change is not backwards compatible, best to use the order:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually I misread the purpose of this PR, shouldn't we be replicating matplotlibs arguments? Can you indicate why you want to make this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ah yes, thanks - @mosc9575 please ignore part of my previous comment let's keep There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Just for consistency really, as in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I opend this issue, because Please let me know if you think this shouldn't be changed at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was reading the matplotlib documentation for a while and the same problem can be found there. I will wait for a response to my issue #21795 and change both in one step, if this is approved. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think we could also accept color size and and not deprecate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, agreed, I'd go with:
Conversely, for
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Matplolib won't change and I think the sugessted changes by @MarcoGorelli are good. I try to edit my PR soon. |
||
""" | ||
Create a scatter plot with varying marker point size and color. | ||
|
||
|
@@ -1601,7 +1601,7 @@ def scatter(self, x, y, s=None, c=None, **kwargs): | |
y : int or str | ||
The column name or column position to be used as vertical | ||
coordinates for each point. | ||
s : str, scalar or array-like, optional | ||
size : str, scalar or array-like, optional | ||
The size of each point. Possible values are: | ||
|
||
- A string with the name of the column to be used for marker's size. | ||
|
@@ -1614,7 +1614,7 @@ def scatter(self, x, y, s=None, c=None, **kwargs): | |
|
||
.. versionchanged:: 1.1.0 | ||
|
||
c : str, int or array-like, optional | ||
color : str, int or array-like, optional | ||
The color of each point. Possible values are: | ||
|
||
- A single color string referred to by name, RGB or RGBA code, | ||
|
@@ -1653,7 +1653,7 @@ def scatter(self, x, y, s=None, c=None, **kwargs): | |
... columns=['length', 'width', 'species']) | ||
>>> ax1 = df.plot.scatter(x='length', | ||
... y='width', | ||
... c='DarkBlue') | ||
... color='DarkBlue') | ||
|
||
And now with the color determined by a column as well. | ||
|
||
|
@@ -1662,10 +1662,10 @@ def scatter(self, x, y, s=None, c=None, **kwargs): | |
|
||
>>> ax2 = df.plot.scatter(x='length', | ||
... y='width', | ||
... c='species', | ||
... color='species', | ||
... colormap='viridis') | ||
""" | ||
return self(kind="scatter", x=x, y=y, s=s, c=c, **kwargs) | ||
return self(kind="scatter", x=x, y=y, s=size or s, c=color or c, **kwargs) | ||
|
||
def hexbin(self, x, y, C=None, reduce_C_function=None, gridsize=None, **kwargs): | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can deprecate but not rename as that is a breaking change
these are matpotlib names but not objecting to the change per se
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point but I need some help to solve it. What is best practice in this situation and how does a deprication warning work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mosc9575 check some other PRs which deprecate arguments for examples https://github.com/pandas-dev/pandas/pulls?q=is%3Apr+depr+is%3Amerged+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jreback I used the wrong word. I did not "rename", I added
size
andcolor
to avoid braking code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't keep both in the signature, that'd be confusing
I'd suggest:
color
andsize
in the signaturecolor
isNone
, takec
fromkwargs
(likewise forsize
ands
)color
andc
color
andsize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MarcoGorelli Thank you. I go with your suggestions. I will edit my PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks - will also need tests to cover the new behaviour