Re: [Matplotlib-users] Feature request: automatic scaling of subplots, margins, etc
Since I just posted an almost-identical question, it's no surprise that I agree this would be a useful feature. Reason #1) I create hundreds of quick throwaway figures every day, often in an automated way, and don't have time to fine-tune them. Reason #2) a newbie to matplotlib might be turned off by one ugly figure, when in fact matplotlib is capable of producing beautiful figures. The previous suggestion I received was to create a convenience wrapper for the subplot function with some idiot-proof defaults. Can you propose a set of rcParams that satisfies this criterion? This one fixes the specific issue you raise: matplotlib.rcParams['figure.subplot.hspace'] = .5 Although it will rear its ugly head again once the number of subplots reaches 5 or 6. Personally I rarely use more than 4x4, and if I did I would certainly increase the figsize. I find that setting all text sizes to be as small as possible also helps. My most commonly encountered issue is overlapping x-tick labels, because most of my plots have samples on the x-axis and therefore hundreds of thousands of points. The real solution of course is to calculate exactly where every piece of text actually is, detect overlaps, and adjust. That is certainly beyond my ability or inclination to implement. In the mean time, it would be nice to have a simple idiot-proof flag that blindly fixes some common problems. On Fri, May 6, 2011 at 1:20 AM, Daniel Mader danielstefanma...@googlemail.com wrote: Hi, almost every time I create a somewhat more complex figure I have to fight with the not too smart positioning of the plots and the size of margins around the axes. From many postings here I have learned that this is the absolute intention, i.e. it is broken by design unless the programmer takes care about this. I have to admin that I do not really get this idea. I am aware that the defaults will not change anytime soon and so I'd like to ask for an idiot-proof mode: this could be enabled by an rcParam and take care of proper dimensions, scale axis labels, titles, margins etc so that they don't cover. Here's an example for a matplotlib script which is a simple as it can get and demonstrates the broken layout which a user gets by default. import scipy import pylab x = scipy.linspace(-50,50, 100) y1 = scipy.rand(100) y2 = scipy.sin(x) y3 = y1 + y2 fig = pylab.figure() ax1 = fig.add_subplot(311) ax2 = fig.add_subplot(312) ax3 = fig.add_subplot(313) ax1.plot(x, y1) ax2.plot(x, y2) ax3.plot(x, y3) ax1.set_title('some title') ax2.set_title('some title') ax3.set_title('some title') pylab.show() Of course, one can adjust the figsize but the results are still far from being adorable. The spacing around the sublplots increases for no apparent reason while the spacing between the subplot remains the same so that everything looks cramped... Thank you many times in advance, best regards, Daniel -- WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Subplot x-tick labels overlap with each other and with titles
Hi Whenever I create figures with at least 3x3 subplots, the x-tick labels overlap with each other and they also overlap with the title of the adjacent subplot, rendering the entire figure illegible. I know that I can fine-tune the plot to look exactly the way I want with wspace and hspace for instance, but I don't understand why this is the default behavior. I wonder if I have a system font issue, such that matplotlib thinks the fonts are smaller than they really are. My questions: 1) Is this the intended behavior of matplotlib, or is there something wrong with my installation? 2) Assuming I don't have an installation issue, is there a very general parameter I can change so that the overlap doesn't occur, rather than manually adjusting every figure? Minimal code to reproduce the problem: import numpy as np import matplotlib.pyplot as plt plt.figure() plt.subplot(331) plt.subplot(334) plt.plot(np.arange(1)) plt.title('Title') plt.show() I'm attaching the output figure, although I'm not sure if the list accepts attachments. The x-tick labels on subplot 334 overlap each other, and the title of subplot 334 overlaps with the x-tick labels in subplot 331. System: Ubuntu 10.04 x64 All packages are the stable versions from Synaptic, including ipython, python, numpy, matplotlib 0.99.1.1 I've also tried the Enthought distribution with matplotlib 1.0.1 and the results are the same I've tried both Wx and Tk backends and the results are the same I've tried `matplotlib.rcParams['xtick.labelsize'] = 'x-small'`, and this does make the labels smaller, but for sufficiently large numbers the overlap still occurs. Thanks for any help! Chris attachment: output.png-- WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Subplot x-tick labels overlap with each other and with titles
Hi Whenever I create figures with at least 3x3 subplots, the x-tick labels overlap with each other and they also overlap with the title of the adjacent subplot, rendering the entire figure illegible. I know that I can fine-tune the plot to look exactly the way I want with wspace and hspace for instance, but I don't understand why this is the default behavior. I wonder if I have a system font issue, such that matplotlib thinks the fonts are smaller than they really are. My questions: 1) Is this the intended behavior of matplotlib, or is there something wrong with my installation? 2) Assuming I don't have an installation issue, is there a very general parameter I can change so that the overlap doesn't occur, rather than manually adjusting every figure? Minimal code to reproduce the problem: import numpy as np import matplotlib.pyplot as plt plt.figure() plt.subplot(331) plt.subplot(334) plt.plot(np.arange(1)) plt.title('Title') plt.show() I'm attaching the output figure, although I'm not sure if the list accepts attachments. The x-tick labels on subplot 334 overlap each other, and the title of subplot 334 overlaps with the x-tick labels in subplot 331. System: Ubuntu 10.04 x64 All packages are the stable versions from Synaptic, including ipython, python, numpy, matplotlib 0.99.1.1 I've also tried the Enthought distribution with matplotlib 1.0.1 and the results are the same I've tried both Wx and Tk backends and the results are the same I've tried `matplotlib.rcParams['xtick.labelsize'] = 'x-small'`, and this does make the labels smaller, but for sufficiently large numbers the overlap still occurs. Thanks for any help! Chris attachment: output.png-- WhatsUp Gold - Download Free Network Management Software The most intuitive, comprehensive, and cost-effective network management toolset available today. Delivers lowest initial acquisition cost and overall TCO of any competing solution. http://p.sf.net/sfu/whatsupgold-sd___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users