Comments (8)
Sorry, I got confused.
The expected behavior of matplotlib is for the categories to be displayed from bottom-to-top.
But within the categories, the bars should display in proper order of the legend.
The current barh function gives this plot with the sample code:
Flipping it with plt.gca().invert_yaxis()
gives:
What we would ideally want is a barh function that preserves the X-Y-Z ordering from bottom to top while ordering the bars as C-B-A from bottom to top.
I am working on implementing this.
from pandas.
Thanks for the report. Can you provide a full reproducible example.
from pandas.
I was able to reproduce it with the following simple bar plot:
data = pd.DataFrame({
'A': [3, 4, 2],
'B': [1, 2, 3],
'C': [4, 1, 2]
}, index=['X', 'Y', 'Z'])
data.plot.barh()
plt.show()
As reported, the legend follows the reverse order of the bars.
If this should be fixed I can begin working on a solution.
from pandas.
Thanks, the solution would just be plt.gca().invert_yaxis()
I think.
from pandas.
I agree - this is a bit odd. I'm +1 on a fixing.
from pandas.
I did some further looking and this is expected behavior of matplotlib. The only fix then is to hardcode a y_axis flip. This would cause a lot of issues with backward compatibility and is generally bad practice. I think it should be left as is.
from pandas.
Thanks for reporting back.
I did some further looking and this is expected behavior of matplotlib.
Are there any links you can share in this regard?
from pandas.
We will have to consider cases for all the backends (plotly, bokeh, holoviews, altair etc)
from pandas.
Related Issues (20)
- BUG: Error on to_datetime() after running multiple times in jupyter notebook HOT 1
- PERF: Difference in using zipped pickle files HOT 4
- BUG: Error on query function when the column name has # symbol HOT 1
- BUG: Couldn't run sql: 'Connection' object has no attribute 'cursor' HOT 4
- Surprising behavior: set_index cannot set a MultiIndex from a tuple, only a list HOT 4
- BUG: pandas.to_datetime reports incorrect index when failing. HOT 9
- BUG: Error message in read_csv misleading when using decimal="," HOT 1
- DOC: Add Bodo to out-of-core projects in ecosystem HOT 4
- QST: Is this expected behavior when pd.read_csv() with na_values arguments? HOT 8
- BUG: GroupBy.value_counts doesn't preserve original order for non-grouping rows HOT 6
- pandas.Series.groupby example is not relevant HOT 6
- PERF: Significant Performance Difference in DataFrame.to_csv() with and without Index Reset HOT 2
- BUG: df.to_json causes low precision in floats HOT 5
- DOC: Typo in docs for na_values parameter in pandas.read_csv function HOT 1
- BUILD: Pandas never succeeds, the most time consuming part of using pandas HOT 2
- ENH: extent Styler `to_latex` for index name styling
- String dtype: overview of breaking behaviour changes HOT 2
- BUG: pandas.read_parquet () dtype_backend argument does not get the default value as documented HOT 4
- BUG: pd.Series.duplicated(keep='first'|'last') returns multiple duplicates HOT 2
- DOC: Website opens search when I press Caps Lock HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pandas.