Python Programming/matplotlib
Tools
General
Sister projects
In other projects
matplotlib is a Python library that allows Python to be used like Matlab, visualizing data on the fly. It is able to create plots, histograms, power spectra, bar charts, errorcharts, scatterplots, etc. It can be used from normal Python and also from iPython.
Examples:
Plot a data series that represents the square function:
frommatplotlibimportpyplotaspltdata=[x*xforxinrange(20)]plt.plot(data)plt.show()
Plot a data series that represents the square function but in reverse order, by providing not only the series of the y-axis values but also the series of x-axis values:
frommatplotlibimportpyplotaspltdatax=list(range(20))datax.reverse()datay=[x*xforxinrange(20)]plt.plot(datax,datay)plt.show()
Plot the square function, setting the limits for the y-axis:
frommatplotlibimportpyplotaspltdata=[x*xforxinrange(20)]plt.ylim(-500,500)# Set limits of y-axisplt.plot(data)plt.show()