12.07.2015 Views

Pylab Plotting data Formatting lines Controlling figure windows

Pylab Plotting data Formatting lines Controlling figure windows

Pylab Plotting data Formatting lines Controlling figure windows

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

- solid line -- dashed line-. dash-dot line : dotted line. points , pixelso circle symbols ^ triangle up symbolsv triangle down symbols < triangle left symbols> triangle right symbols s square symbols+ plus symbols x cross symbolsD diamond symbolsb blue g greenr red c cyanm magenta y yellowk black w whiteTable 1: Some of the available format characters for changing the line style, <strong>data</strong> point symbolsand colours.Example The following commands create two <strong>figure</strong>s, plot x 2 and x 4 on the first <strong>figure</strong> and plotx 3 on the second <strong>figure</strong>.from __future__ import divisionfrom scipy import *import pylabx = linspace(0, 1, 100)pylab.<strong>figure</strong>(1)# Create the first <strong>figure</strong>pylab.plot(x, x**2) # Plot on Figure 1pylab.<strong>figure</strong>(2)# Create the second <strong>figure</strong>pylab.plot(x, x**3) # Plot on Figure 2pylab.<strong>figure</strong>(1) # Return to Figure 1pylab.plot(x, x**4) # Plot on Figure 1pylab.show()Changing the axesThe axis command is used to change the ranges of the x and y axes. Callingpylab.axis([xmin, xmax, ymin, ymax])sets the ranges. Calling axis() without any parameters returns the current x and y ranges. Youcan also use the functions xlim and ylim to set the range of only one of the axes.By default <strong>Pylab</strong> scales the axes so that all of the <strong>data</strong> fits on the plot window. This meansthat the x and y might have different length scales. This behaviour can be changed with thefollowing commands.• axis(’equal’) sets the x and y axes to have the same scale. This will make a circle lookcircular.• axis(’scaled’) also makes a circle look circular, but does it by changing the dimensionsof the plot window (and not the axes).2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!