Skip to content

regression: bar plot with multi-column category doesn't work anymore #21386

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

Open
soxofaan opened this issue Jun 8, 2018 · 9 comments
Open

regression: bar plot with multi-column category doesn't work anymore #21386

soxofaan opened this issue Jun 8, 2018 · 9 comments
Labels
Bug Regression Functionality that used to work in a prior pandas version Visualization plotting

Comments

@soxofaan
Copy link
Contributor

soxofaan commented Jun 8, 2018

Code Sample, a copy-pastable example if possible

Doing a bar plot using a multi-column category used to work

df.plot.barh(x=['fruit', 'animal'], y='size')

In pandas 0.22.0:
screen shot 2018-06-08 at 16 34 51

since pandas 0.23.0:
screen shot 2018-06-08 at 16 39 36

Is it intended that this stopped working?
I kind of liked the feature.

@soxofaan
Copy link
Contributor Author

soxofaan commented Jun 8, 2018

using some git bisect magic I found that this commit introduces the ValueError:
d7d8f2d, which refers to PR #18695 and issue #18671

@soxofaan
Copy link
Contributor Author

soxofaan commented Jun 8, 2018

also related: #19699

@gfyoung gfyoung added Visualization plotting Regression Functionality that used to work in a prior pandas version labels Jun 8, 2018
@gfyoung
Copy link
Member

gfyoung commented Jun 8, 2018

cc @TomAugspurger : Labeled as regression, but of course, feel free to modify if change was deliberate.

@daminisatya
Copy link
Contributor

Is the issue still open? If so, I would like to work on this.

@TomAugspurger
Copy link
Contributor

cc @masongallo if you recall the discussion around this.

@soxofaan
Copy link
Contributor Author

@daminisatya yes, as far as I know this is not yet resolved

@masongallo
Copy link
Contributor

A few comments:

  • The change was intentional to conform with the api & docs
  • The signature of barh in pandas is quite confusing to me: df.plot.barh(x=['fruit', 'animal'], y='size') but the fruit,animal actually appears on the y-axis and size appears on the x-axis!
  • The signature of ax.barh in matplotlib actually takes the y-value as its first arg

@soxofaan
Copy link
Contributor Author

@masongallo :
I just used barh to make sure the screenshot was easily readable,
The "feature" also used to work for standard bar in pandas 0.22:
screen shot 2018-06-13 at 10 48 04

The change was intentional to conform with the api & docs

I understand for the use case of line and scatter plots,
but for categorical plots like bar (and pie see lower), I think it would be an interesting feature to bring back support for multi-column based labels. Is there interest for that @TomAugspurger ?

The signature of barh in pandas is quite confusing to me

In my mind, the x/y handling in barh makes sense as I see barh as a flipped version of bar: the x-axis is drawn vertically and y-axis is drawn horizontally. During data exploration, I usually switch between bar and barh functions names to improve readability of the labels, and in that process I don't want to also change the arguments of those functions. That being said, I think the axis handling of barh is probably another discussion and out of scope of this ticket.

For completeness I also tried it out with pie, but there the x argument seems to be ignored completely, so it kind of works with both 0.22 and 0.23. However, the pie piece labels come from the index instead of the given x column. But that is probably another (known) issue.
screen shot 2018-06-13 at 10 49 45

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Jun 13, 2018 via email

@mroeschke mroeschke added the Bug label May 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Regression Functionality that used to work in a prior pandas version Visualization plotting
Projects
None yet
Development

No branches or pull requests

6 participants