Skip to content

Support for hierarchical labeling of bar-plots #1257

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

Closed
louist87 opened this issue Sep 14, 2012 · 4 comments
Closed

Support for hierarchical labeling of bar-plots #1257

louist87 opened this issue Sep 14, 2012 · 4 comments

Comments

@louist87
Copy link

With the increasing popularity of the Pandas data-analysis library, more and more users can be expected to want to plot hierarchically organized data.

Below is an example of a Pandas dataframe:

Group Local Global Attn  mean
ASub  LD    GD     Attn    -0
                   Dist    -0
            GS     Attn    -0
                   Dist    -0
      LS    GD     Attn    -0
                   Dist    -0
            GS     Attn    -0
                   Dist    -0
DSub  LD    GD     Attn    -0
                   Dist     0
            GS     Attn    -0
                   Dist    -0
      LS    GD     Attn    -0
                   Dist    -0
            GS     Attn    -0
                   Dist    -0

(Note that the above mean column values are not zero, but very small floats)

And here is the resulting matplotlib.pyplot bar graph:
Graphical representation of above data.  Note that the values are not zero, but extremely small floats

It would be nice, and I imagine relatively simple, to add support for hierarchical labeling of the x-axis. For clarity, I mean that I should be able to create a tree-like structure of labels that shows how the left half of the bars belong to the ASub group, the left half of which belongs to the LD group of the Local parameter, etc...

Thoughts?

@dmcdougall
Copy link
Member

Could you maybe draw a quick and dirty prototype of how you think this should look?

@louist87
Copy link
Author

@dmcdougall, Sure thing!

Below is the best solution I've come across so far, and it was generated with the plotting functions in Pandas. My understanding is that matplotlib subtends the plotting functionality of Pandas, but that Pandas has a few extra functions that make it easier to plot DataFrames and such. (I could be wrong about this).

In any case, this is more or less what I was shooting for, although it could be prettier:

pandas plot output

It would be nice if we could do something like this:

Hierarchical labelling concept

Does this make things clear?

@WeatherGod
Copy link
Member

Yes, that makes things clearer, at least to me.

One possible way to go about this is to interpret a dictionary of data to
mean hierarchical display (one would presumedly use OrderedDictionary if
they care about the order the bars show up. The key would be the label,
and the value could be a numerical value or another dictionary. Note,
though, I don't think we usually play around with axis labels like this
from within the bar() function. Furthermore, bar() is already a major
beast of a function. I would tread carefully here.

@anntzer
Copy link
Contributor

anntzer commented Nov 24, 2017

I agree with @story645 that #6321 is a dupe, but I'll close this one as the other has what I believe is a clearer example graph.

@anntzer anntzer closed this as completed Nov 24, 2017
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants