New release
matplotlib 0.98.3 is a major release which requires python2.4 or 2.5 and numpy 1.1. It contains significant improvements and may require some advanced users to update their code; see migration and API_CHANGES. We are supporting a maintenance branch of the older code available at matplotlib 0.91.4. Basemap users see basemap-readme for upgrade instructions

Donate
Help support matplotlib development by donating to fund developer sprints and other matplotlib development costs.

Matplotlib
Home
What's New
Download
Installing
Screenshots
Examples (zip)
Mailing lists
Donate

Documentation
Tutorial
User's Guide 
API tutorial
Event handling
API Reference
FAQ
Cookbook / wiki
pylab interface
Class library
Backends
Toolkits
Fonts
Interactive
Goals

Other
Credits
License

  

Matplotlib sample code and figures

Click on any image to enlarge

Code: simple_plot.py
The most basic plot, with text labels


Code: subplot_demo.py
Multiple regular axes are created with subplot. This is a screenshot of the matplotlib figure window. Navigation controls on the bottom of the figure support a variety of pan and zoom modes.


Code: histogram_demo.py
The hist command automatically generates histograms and will return the bin counts or probabilities


Code: path_patch_demo.py
You can add aribitrary paths in matplotlib as of release 0.98. See the path module


Code: ellipse_demo.py
In support of the Phoenix mission to Mars, which used matplotlib in ground tracking of the spacecraft, Michael Droettboom built on work by Charlie Moad to provide an extremely accurate 8-spline approximation to elliptical arcs in the viewport. This provides a scale free, accurate graph of the arc regardless of zoom level


Code: barchart_demo.py
The bar command takes error bars as an optional argument. You can also use up and down bars, stacked bars, 'candlestick' bars, etc, ... See bar_stacked.py for another example. You can make horizontal bar charts with the barh command.


Code: pie_demo.py
The pie command uses a matlab(TM) compatible syntax to produce py charts. Optional features include auto-labeling the percentage of area, "exploding" one or more wedges out from the center of the pie, and a shadow effect. Take a close look at the attached code that produced this figure; nine lines of code.


Code: table_demo.py
The table is an interface to the Table class to build tables on the axes.


Code: scatter_demo2.py
The scatter command makes a scatter plot with (optional) size and color arguments. This example plots changes in Intel's stock price from one day to the next with the sizes coding trading volume and the colors coding price change in day i. Here the alpha attribute is used to make semitransparent circle markers with the Agg backend


Code: slider_demo.py
Matplotlib has basic GUI widgets that are independent of the graphical user interface you are using, allowing you to write cross GUI figures and widgets. See widgets classdocs and examples/widgets/*.py


Code: fill_demo.py
The fill, command lets you plot filled polygons. Thanks to Andrew Straw for providing this function.


Code: date_demo.py
You can plot date data with major and minor ticks and custom tick formatters for both the major and minor ticks; see ticker and dates for details and usage. This plot uses the finance module to retrieve stock data.


Code: finance_work2.py
You can make much more sophisticated financial plots. This example emulates one of the ChartDirector financial plot. Some of the data in the plot, are real financial data, some are random traces that I used since the goal was to illustrate plotting techniques, not market analysis!


Code: plotmap.py
Jeff Whitaker provided this example showing how to efficiently plot a collection of lines over a colormap image using the basemap matplotlib toolkit (available from the download page). Many map projections are handled via the proj4 library: cylindrical equidistant, mercator, lambert conformal conic, lambert azimuthal equal area, albers equal area conic and stereographic. See the entry on the wiki.


Code: log_shot.py
The semilogx, semilogy and loglog commands generate log scaling on the respective axes. The lower subplot uses a base10 log on the xaxis and a base 4 log on the y. Thanks to Andrew Straw, Darren Dale and Gregory Lielens for contributions to the log scaling infrastructure.


Code: polar_demo.py
The polar command generates polar plots.


Code: legend_demo.py
The legend command automatically generates figure legends, with matltab compatible legend placement commands. Thanks to Charles Twardy for input on the legend command


Code: mathtext_examples.py
A sampling of the many TeX expressions now supported by matplotlib's internal mathtext engine. The mathtext module provides TeX style mathematical expressions using freetype2 and the BaKoMa computer modern or STIX fonts. See the mathtext module for usage, licensing and backend information. matplotlib mathtext is an independent implementation, and does not required TeX or any external packages installed on your computer.


Code: wheeler_demo.py
Plot of Level Set (LSM), Phase Field (PFM) and Sharp Interface Models to demonstrate schematically the difference between the three models. The green and blue equations govern the behaviors of the LSM and PFM respectively. The distance delta represents the nominal interface width. The LSM requires an algorithmic construct while the PFM is a first principles approach. Thanks to Daniel Wheeler for this nice example of TeX rendering with usetex..


Code: eeg.py
You can embed matplotlib into pygtk, wxpython, Tk, FLTK or Qt applications. Here is a screenshot of an eeg viewer written in pygtk using matplotlib; the lower axes is using specgram to plot the spectrogram of one of the EEG channels. The code demo linked above is a much simpler example of embedding matplotlib in pygtk. For an example of how to use the navigation toolbar in your applications, see embedding_in_gtk2.py. If you want to use matplotlib in a wx application, see embedding_in_wx2.py. If you want to work with glade, see mpl_with_glade.py



Powered by
YAPTU!
Matlab® is a registered trademark of The MathWorks