0

I'm plotting histogram for a group of data, the histograms looks like this:

enter image description here

The problem is that, every histogram has its own ylim. I want to set them to the same, so I can compare them directly, something like this:

enter image description here

How can I do that?

I can set the plotting axis by plt.axis([-5,360,0,3000]), but this also require I know the axis range before hand. How can I get such value?

Cœur
  • 37,241
  • 25
  • 195
  • 267
ZK Zhao
  • 19,885
  • 47
  • 132
  • 206
  • Do you means `ax.get_ylim()`? – HYRY Mar 21 '16 at 05:58
  • @HYRY, yes, but how can I know the limit beforehand? Or I should first `ax.get_y_lim()`, and then plot in the new range again? – ZK Zhao Mar 21 '16 at 08:24
  • Look at `sharey`. Here's an example: http://matplotlib.org/examples/pylab_examples/subplots_demo.html – Mel Mar 21 '16 at 08:28
  • 1
    Possible duplicate of [plotting autoscaled subplots with fixed limits in matplotlib](http://stackoverflow.com/questions/13612610/plotting-autoscaled-subplots-with-fixed-limits-in-matplotlib) – Mel Mar 21 '16 at 08:29
  • also `ax.set_ylim([min, max])` will set them to what ever you want. – tacaswell Mar 22 '16 at 00:28

0 Answers0