Skip to content

Latest commit

 

History

History
281 lines (185 loc) · 7.69 KB

screenshots.rst

File metadata and controls

281 lines (185 loc) · 7.69 KB

Screenshots

Here you will find a host of example figures with the code that generated them

Simple Plot

The most basic ~matplotlib.pyplot.plot, with text labels

mpl_examples/pylab_examples/simple_plot.py

Subplot demo

Multiple regular axes (numrows by numcolumns) are created with the ~matplotlib.pyplot.subplot command.

mpl_examples/pylab_examples/subplot_demo.py

Histograms

The ~matplotlib.pyplot.hist command automatically generates histograms and will return the bin counts or probabilities

mpl_examples/statistics/histogram_demo_features.py

Path demo

You can add arbitrary paths in matplotlib as of release 0.98. See the matplotlib.path.

mpl_examples/api/path_patch_demo.py

mplot3d

The mplot3d toolkit (see toolkit_mplot3d-tutorial and mplot3d-examples-index) has support for simple 3d graphs including surface, wireframe, scatter, and bar charts (added in matlpotlib-0.99). Thanks to John Porter, Jonathon Taylor and Reinier Heeres for the mplot3d toolkit. The toolkit is included with all standard matplotlib installs.

mpl_examples/mplot3d/surface3d_demo.py

Ellipses

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 (see ~matplotlib.patches.Arc) in the viewport. This provides a scale free, accurate graph of the arc regardless of zoom level

mpl_examples/pylab_examples/ellipse_demo.py

Bar charts

The ~matplotlib.pyplot.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 ~matplotlib.pyplot.barh command.

mpl_examples/pylab_examples/barchart_demo.py

Pie charts

The ~matplotlib.pyplot.pie command uses a MATLAB compatible syntax to produce pie 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.

mpl_examples/pie_and_polar_charts/pie_demo_features.py

Table demo

The ~matplotlib.pyplot.table command will place a text table on the axes

mpl_examples/pylab_examples/table_demo.py

Scatter demo

The ~matplotlib.pyplot.scatter command makes a scatter plot with (optional) size and color arguments. This example plots changes in Google 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 (see what-is-a-backend)

mpl_examples/pylab_examples/scatter_demo2.py

Slider demo

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 matplotlib.widgets and the widget examples <examples/widgets>

mpl_examples/widgets/slider_demo.py

Fill demo

The ~matplotlib.pyplot.fill command lets you plot filled polygons. Thanks to Andrew Straw for providing this function

mpl_examples/lines_bars_and_markers/fill_demo.py

Date demo

You can plot date data with major and minor ticks and custom tick formatters for both the major and minor ticks; see matplotlib.ticker and matplotlib.dates for details and usage.

mpl_examples/api/date_demo.py

Financial charts

You can make much more sophisticated financial plots. This example emulates one of the ChartDirector financial plots. 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!

mpl_examples/pylab_examples/finance_work2.py

Basemap demo

Jeff Whitaker's toolkit_basemap add-on toolkit makes it possible to plot data on many different map projections. This example shows how to plot contours, markers and text on an orthographic projection, with NASA's "blue marble" satellite image as a background.

pyplots/plotmap.py

Log plots

The ~matplotlib.pyplot.semilogx, ~matplotlib.pyplot.semilogy and ~matplotlib.pyplot.loglog functions generate log scaling on the respective axes. The lower subplot uses a base10 log on the xaxis and a base 4 log on the yaxis. Thanks to Andrew Straw, Darren Dale and Gregory Lielens for contributions to the log scaling infrastructure.

mpl_examples/pylab_examples/log_demo.py

Polar plots

The ~matplotlib.pyplot.polar command generates polar plots.

mpl_examples/pylab_examples/polar_demo.py

Legends

The ~matplotlib.pyplot.legend command automatically generates figure legends, with MATLAB compatible legend placement commands. Thanks to Charles Twardy for input on the legend command

mpl_examples/pylab_examples/legend_demo.py

Mathtext_examples

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 matplotlib.mathtext module for additional. matplotlib mathtext is an independent implementation, and does not required TeX or any external packages installed on your computer. See the tutorial at mathtext-tutorial.

mpl_examples/pylab_examples/mathtext_examples.py

Native TeX rendering

Although matplotlib's internal math rendering engine is quite powerful, sometimes you need TeX, and matplotlib supports external TeX rendering of strings with the usetex option.

pyplots/tex_demo.py

EEG demo

You can embed matplotlib into pygtk, wxpython, Tk, FLTK or Qt applications. Here is a screenshot of an eeg viewer called pbrain which is part of the NeuroImaging in Python suite NIPY. Pbrain is written in pygtk using matplotlib. The lower axes uses ~matplotlib.pyplot.specgram to plot the spectrogram of one of the EEG channels. For an example of how to use the navigation toolbar in your applications, see user_interfaces-embedding_in_gtk2. If you want to use matplotlib in a wx application, see user_interfaces-embedding_in_wx2. If you want to work with glade, see user_interfaces-mpl_with_glade.

image