Y axis scaling with Matplotlib in Python

How to scale y axis with Matplotlib ? I do not want to change y-limit, I just want to expand the physical space.

^      ^
|      |
|      |
+----> |
Before +---->
       After
+5
source share
2 answers

Just use a larger height value when you instantiate the shape:

from pylab import *
x = linspace(0, 10*pi, 2**10)
y = sin(x)
figure(figsize=(5, 10))
plot(x, y)
show()

Where figsize=(width, height)and by default - (8, 6). Values ​​are in inches (the keyword dpiarg can be used to determine the DPI for the shape, and there is a default value in yours matplotlibrc)

For an already created figure, I believe that there is a method set_size_inches(width, height).

+7
source

subplots_adjust :

fig.subplots_adust (bottom = 0.05, top = 0.95)

,

+2

All Articles