|
1 | 1 | .. _howto-faq: |
2 | 2 |
|
3 | | -********* |
4 | | -HOWTO FAQ |
5 | | -********* |
| 3 | +***** |
| 4 | +Howto |
| 5 | +***** |
| 6 | + |
| 7 | +.. _howto-subplots-adjust: |
| 8 | + |
| 9 | +How do I move the edge of my axes area over to make room for my tick labels? |
| 10 | +============================================================================ |
| 11 | + |
| 12 | +For subplots, you can control the default spacing on the left, right, |
| 13 | +bottom, and top as well as the horizontal and vertical spacing between |
| 14 | +multiple rows and columns using the |
| 15 | +:meth:`matplotlib.figure.Figure.subplots_adjust` method (in pyplot it |
| 16 | +is :func:`~matplotlib.pyplot.subplots_adjust`). For example, to move |
| 17 | +the bottom of the subplots up to make room for some rotated x tick |
| 18 | +labels:: |
| 19 | + |
| 20 | + fig = plt.figure() |
| 21 | + fig.subplots_adjust(bottom=0.2) |
| 22 | + ax = fig.add_subplot(111) |
| 23 | + |
| 24 | +You can control the defaults for these parameters in your |
| 25 | +:file:`matplotlibrc` file; see :ref:`customizing-matplotlib`. For |
| 26 | +example, to make the above setting permanent, you would set:: |
| 27 | + |
| 28 | + figure.subplot.bottom : 0.2 # the bottom of the subplots of the figure |
| 29 | + |
| 30 | +The other parameters you can configure are, with their defaults |
| 31 | + |
| 32 | +*left* = 0.125 |
| 33 | + the left side of the subplots of the figure |
| 34 | +*right* = 0.9 |
| 35 | + the right side of the subplots of the figure |
| 36 | +*bottom* = 0.1 |
| 37 | + the bottom of the subplots of the figure |
| 38 | +*top* = 0.9 |
| 39 | + the top of the subplots of the figure |
| 40 | +*wspace* = 0.2 |
| 41 | + the amount of width reserved for blank space between subplots |
| 42 | +*hspace* = 0.2 |
| 43 | + the amount of height reserved for white space between subplots |
| 44 | + |
| 45 | +If you want additional control, you can create an |
| 46 | +:class:`~matplotlib.axes.Axes` using the |
| 47 | +:func:`~matplotlib.pyplot.axes` command (or equivalently the figure |
| 48 | +:meth:`matplotlib.figure.Figure.add_axes` method), which allows you to |
| 49 | +specify the location explicitly:: |
| 50 | + |
| 51 | + ax = fig.add_axes([left, bottom, width, height]) |
| 52 | + |
| 53 | +where all values are in fractional (0 to 1) coordinates. See |
| 54 | +`axes_demo.py <http://matplotlib.sf.net/examples/axes_demo.py>`_ for |
| 55 | +an example of placing axes manually. |
6 | 56 |
|
7 | 57 | .. _howto-ticks: |
8 | 58 |
|
|
0 commit comments