Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scaling the y-axis with Matplotlib in Python

How to scale the y-axis with Matplotlib? I don't want to change the y-limit, I just want to extend the physical space.

^      ^
|      |
|      |
+----> |
Before +---->
       After
like image 767
Roman Glass Avatar asked Dec 30 '08 23:12

Roman Glass


1 Answers

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

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 defaults to (8, 6). Values are in inches (the dpi keyword arg can be used to define the DPI for the figure, and there's a default value in your matplotlibrc file)

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

like image 195
Autoplectic Avatar answered Sep 26 '22 01:09

Autoplectic