0

I want to make the plot smaller, so it can save some space in print. However, when I make it smaller, the grid will be too tight:

enter image description here

Honestly, I don't get it. Why can't matplotlib auto-detect that this image is too small that the lable should be with a bigger interval?

So, How can I make the grid more sparse, so the lables won't overlap with each other?

Additionally, the title will also collapse with the labels. I can set it manually, by plt.suptitle(title, y=1.08). So it will look better

enter image description here

But I'm wondering if there is anyway to do it automatically?

Note: I'm using seaborn, but I tried with pure matplotlib, same problem.

ZK Zhao
  • 19,885
  • 47
  • 132
  • 206
  • Are you manually specifying the ytick locations? – Suever Jul 09 '16 at 15:18
  • @Suever, no this occurs when I use a small figure size. – ZK Zhao Jul 09 '16 at 15:38
  • 1
    Check http://stackoverflow.com/questions/13052844/matplotlib-how-to-decrease-density-of-tick-labels-in-subplots. – Vadim Shkaberda Jul 09 '16 at 17:45
  • @VadimShkaberda This is very helpful. Is there any way I can do this automatically? For example, when I set fig = plt.figure(figsize=(14,2)), when the height is too tight, then triggers the `locator_params`? – ZK Zhao Jul 10 '16 at 04:39
  • The best I can suggest is to use for loop after `fig = plt.figure(figsize=(14,2))` like this (for 3 rows and 2 cols): `for i in range(6): plt.subplot(3, 2, i+1); plt.locator_params(axis='y', nbins=#number)`. Then plot your data as usual. – Vadim Shkaberda Jul 10 '16 at 08:21

0 Answers0