Académique Documents
Professionnel Documents
Culture Documents
Aman W
Department of Applied Physics
University of Gondar
Contents
Line style
Color "-": solid line
r: red "--": dashed line
g: green ".": mark points with a
b: blue point
c: cyan "o": mark points with a
circle
m: magenta
"s": mark points with a
y: yellow
square
k: black For instance
w: white 'r-^ red, dot-dash, triangles
Pylab: xlim, ylim, xlabel, ylabel
xlim
Get or set the *x* limit of the current axes.
ylim
Get of set the *y* limit of the current axes.
xlabel
Set the *x* axis label of the current axes.
ylabel
Set the *y* axis label of the current axes.
Once you have created the figure (using the plot command)
and added any labels, legends etc, you
have two options to save the plot.
You can display the figure (using show) and interactively
save it by clicking on the disk icon.
You can (without displaying the figure) save it directly
from your Python code.
The command to use is savefig.
The format is determined by the extension of the le name you
provide.
Here is an example which saves the plot
import pylab
x = [ 0.5, 1.0, 2.0, 4.0, 7.0, 10.0 ]
y = [ 1.0, 2.4, 1.7, 0.3, 0.6, 1.8 ]
pylab . plot (x, y, label =x-y plot')
pylab.xlabel('x-axis')
pylab.ylabel('y-axis')
pylab . savefig ('myplot .png ') #
saves png file
pylab . savefig ('myplot .eps ') #
saves eps file
pylab . savefig ('myplot .pdf ') #
saves pdf file