问题
I'm making histograms using pandas and I find this approach convenient.
For example if I do:
df['plotvar'].hist(by='Zone')
I get
But now I want to add the 95%CI on each of these subgroups, and of course the intervals are different for each group. I could do it just using plt.axvline in matplotlib, but not sure how to do it when I've made the original plots using pandas. TIA for any inputs/suggestions.
edit: I shoudl add that I already know what the 95%CI values are. This is just a plotting question (how to apply the axvline to each of these subplots). Thx.
回答1:
DataFrame.hist() with by= returns the array of matplotlib Axes, so you could grab that and then iterate over it.
For similar functionality that speaks pandas but has more flexible features you could use the FacetGrid object from seaborn.
来源:https://stackoverflow.com/questions/24917580/is-there-a-way-to-pass-different-vertical-lines-to-each-subplot-when-using-panda