Skip to content

ENH/VIZ: Allowing s parameter of scatter plots to be a column name #33107

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

Conversation

SultanOrazbayev
Copy link
Contributor

@SultanOrazbayev SultanOrazbayev commented Mar 28, 2020

This PR is a continuation of #32937 (made an error when pulling changes from the master).

I had a more elaborate decision tree for what to do with a passed size variable s, here #32937, but in the end decided to go with the simpler version since the other checks are redundant (they would contain s=s or pass).

@datapythonista datapythonista changed the title added a test for scatter with variable marker size BUG/VIZ: Allowing s parameter of scatter plots to be a column name Mar 31, 2020
@datapythonista datapythonista changed the title BUG/VIZ: Allowing s parameter of scatter plots to be a column name ENH/VIZ: Allowing s parameter of scatter plots to be a column name Mar 31, 2020
Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks @SultanOrazbayev

@TomAugspurger if you want to have a look...

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the plot.scatter docstring to indicate that a column label is also accepted, and a ..versionchanged 1.1.0 noting that labels are accepted starting in 1.1.0?

# this refers to GH 32904
df = DataFrame(np.random.random((10, 3)) * 100, columns=["a", "b", "c"],)

_check_plot_works(df.plot.scatter, x="a", y="b", s="c")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have some assertion here that the argument actually had an effect. Perhaps something like

Suggested change
_check_plot_works(df.plot.scatter, x="a", y="b", s="c")
ax = df.plot.scatter(x="a", y="b", s="c")
assert len(set(ax.collections[0].get_sizes())) > 1

Copy link
Contributor Author

@SultanOrazbayev SultanOrazbayev Mar 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm confused about the correct way of using versionchanged. I read https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html and I think this is suitable:

https://github.com/SultanOrazbayev/pandas/blob/4d5db4ad9b30bb51e9c9bbe130ceff4dfb989320/pandas/plotting/_core.py#L1471-L1477

However, not sure about the indentation and whether second argument to versionchanged is needed (searching pandas code shows that sometimes the description is added, but it's not everywhere).

@TomAugspurger TomAugspurger merged commit 1357114 into pandas-dev:master Mar 31, 2020
@TomAugspurger
Copy link
Contributor

Thanks @SultanOrazbayev. Congrats on your first PR to pandas!

@TomAugspurger TomAugspurger added this to the 1.1 milestone Mar 31, 2020
@SultanOrazbayev
Copy link
Contributor Author

Thank you very much for your help! Glad it worked out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants