Some examples of how to annotate points in figures. You specify an annotation point xy=(x,y) and a text point xytext=(x,y) for the annotated points and text location, respectively. Optionally, you can specify the coordinate system of xy and xytext with one of the following strings for xycoords and textcoords (default is 'data') 'figure points' : points from the lower left corner of the figure 'figure pixels' : pixels from the lower left corner of the figure 'figure fraction' : 0,0 is lower left of figure and 1,1 is upper, right 'axes points' : points from lower left corner of axes 'axes pixels' : pixels from lower left corner of axes 'axes fraction' : 0,1 is lower left of axes and 1,1 is upper right 'offset points' : Specify an offset (in points) from the xy value 'data' : use the axes data coordinate system Optionally, you can specify arrow properties which draws and arrow from the text to the annotated point by giving a dictionary of arrow properties Valid keys are width : the width of the arrow in points frac : the fraction of the arrow length occupied by the head headwidth : the width of the base of the arrow head in points shrink : move the tip and base some percent away from the annotated point and text any key for matplotlib.patches.polygon (eg facecolor) For physical coordinate systems (points or pixels) the origin is the (bottom, left) of the figure or axes. If the value is negative, however, the origin is from the (right, top) of the figure or axes, analogous to negative indexing of sequences.
This example is only interesting when ran in interactive mode
Make a "broken" horizontal bar plot, ie one with gaps
Clip a line according to the current xlimits, and change the marker style when zoomed in
Make a colorbar as a separate figure.
You can pass a custom Figure constructor to figure if youy want to derive from the default Figure. This simple example creates a figure with a figure title
When plotting daily data, a frequent request is to plot the data ignoring skips, eg no extra spaces for weekends. This is particularly common in financial time series, when you may have data for M-F and not Sat, Sun and you don't want gaps in the x axis. The approach is to simply use the integer index for the xdata and a custom tick Formatter to get the appropriate date string for a given index.
Illustration of upper and lower limit symbols on errorbars
A little example that shows how the various indexing into the font tables relate to one another. Mainly for mpl developers....
Hatching (pattern filled polygons) is supported currently on PS backend only. See the set_patch method in http://matplotlib.sf.net/matplotlib.patches.html#Patch for details
Show how to use a lasso to select a set of points and get the indices of the selected points. A callback is used to change the color of the selected points This is currently a proof-of-concept implementation (though it is usable as is). There will be some refinement of the API and the inside polygon detection routine.
This file was written to test matplotlib's autolegend placement algorithm, but shows lots of different ways to create legends so is useful as a general examples Thanks to John Gill and Phil ?? for help at the matplotlib sprint at pycon 2005 where the auto-legend support was written.
Demonstrates how to convert mathtext to a wx.Bitmap for display in various controls on wxPython.
compute the mean and stddev of 100 data sets and plot mean vs stddev. When you click on one of the mu, sigma points, plot the raw data from the dataset that generated the mean and stddev
This is an example to show how to build cross-GUI applications using matplotlib event handling to interact with objects on the canvas
An example of how to use pylab to manage your figure windows, but modify the GUI by accessing the underlying gtk widgets
Demonstration of quiver and quiverkey functions. This is using the new version coming from the code in quiver.py. Known problem: the plot autoscaling does not take into account the arrows, so those on the boundaries are often out of the picture. This is *not* an easy problem to solve in a perfectly general way. The workaround is to manually expand the axes.
matlab(TM) and pylab allow you to use setp and get to set and get object properties, as well as to do introspection on the object set To set the linestyle of a line to be dashed, you can do >>> line, = plot([1,2,3]) >>> setp(line, linestyle='--') If you want to know the valid types of arguments, you can provide the name of the property you want to set without a value >>> setp(line, 'linestyle') linestyle: [ '-' | '--' | '-.' | ':' | 'steps' | 'None' ] If you want to see all the properties that can be set, and their possible values, you can do >>> setp(line) set operates on a single instance or a list of instances. If you are in quey mode introspecting the possible values, only the first instance in the sequnce is used. When actually setting values, all the instances will be set. Eg, suppose you have a list of two lines, the following will make both lines thicker and red >>> x = arange(0,1.0,0.01) >>> y1 = sin(2*pi*x) >>> y2 = sin(4*pi*x) >>> lines = plot(x, y1, x, y2) >>> setp(lines, linewidth=2, color='r') get: get returns the value of a given attribute. You can use get to query the value of a single attribute >>> getp(line, 'linewidth') 0.5 or all the attribute/value pairs >>> getp(line) aa = True alpha = 1.0 antialiased = True c = b clip_on = True color = b ... long listing skipped ... Alisases: To reduce keystrokes in interactive mode, a number of properties have short aliases, eg 'lw' for 'linewidth' and 'mec' for 'markeredgecolor'. When calling set or get in introspection mode, these properties will be listed as 'fullname or aliasname', as in
connect the data limits on the axes in one figure with the axes in another. This is not the right way to do this for two axes in the same figure -- use the sharex and sharey property in that case
You can share the x or y axis limits for one axis with another by passing an axes instance as a sharex or sharey kwarg. Changing the axis limits on one axes will be reflected automatically in the other, and vice-versa, so when you navigate with the toolbar the axes will follow each other on their shared axes. Ditto for changes in the axis scaling (eg log vs linear). However, it is possible to have differences in tick labeling, eg you can selectively turn off the tick labels on one axes. The example below shows how to customize the tick labels on the various axes. Shared axes share the tick locator, tick formatter, view limits, and transformation (eg log, linear). But the ticklabels themselves do not share properties. This is a feature and not a bug, because you may want to make the tick labels smaller on the upper axes, eg in the example below. If you want to turn off the ticklabels for a given axes (eg on subplot(211) or subplot(212), you cannot do the standard trick setp(ax2, xticklabels=) because this changes the tick Formatter, which is shared among all axes. But you can alter the visibility of the labels, which is a property setp( ax2.get_xticklabels(), visible=False)
Plot the sparsity pattern of arrays
Emulate an oscilloscope. Requires the animation API introduced in matplotlib 0.84. See http://www.scipy.org/wikis/topical_software/Animations for an explanation. This example uses gtk but does not depend on it intimately. It just uses the idle handler to trigger events. You can plug this into a different GUI that supports animation (GTKAgg, TkAgg, WXAgg) and use your toolkits idle/timer functions.
Test unit support with each of the matplotlib primitive artist types The axes handles unit conversions and the artists keep a pointer to their axes parent, so you must init the artists with the axes instance if you want to initialize them with unit data, or else they will not know how to convert the units to scalars
plot using a variety of cm vs inches conversions. The example shows how default unit instrospection works (ax1), how various keywords can be used to set the x and y units to override the defaults (ax2, ax3, ax4) and how one can set the xlimits using scalars (ax3, current units assumed) or units (conversions applied to get the numbers to current units)
Compare the ellipse generated with arcs versus a polygonal approximation
A mockup "Foo" units class which supports conversion and different tick formatting depending on the "unit". Here the "unit" is just a scalar conversion factor, but this example shows mpl is entirely agnostic to what kind of units client packages use
Plot with radians from the basic_units mockup example package This example shows how the unit class can determine the tick locating, formatting and axis labeling.
Demonstrate unit handling basic_units is a mockup of a true units package used for testing purposed, which illustrates the basic interface that a units package must provide to matplotlib. The example below shows support for unit conversions over masked arrays.
Example to draw a cursor and report the data coords in wx
This example shows how to connect events in one window, eg a mouse press, to another figure window. If you click on a point in the first window, the z and y limits of the second will be adjusted so that the center of the zoom in the second window will be the x,y coords of the clicked point. Note the diameter of the circles in the scatter are defined in points**2, so their size is independent of the zoom
This is an object-orient plotting library. A procedural interface is provided by the companion pylab module, which may be imported directly, e.g. from pylab import * or using ipython: ipython -pylab For the most part, direct use of the object-oriented library is encouraged when programming rather than working interactively. The exceptions are the pylab commands figure(), subplot(), show(), and savefig(), which can greatly simplify scripting. Modules include: axes: defines the Axes class. Most pylab commands are wrappers for Axes methods. The axes module is the highest level of OO access to the library. figure: defines Figure class. artist: defines the Artist base class for all classes that draw things. line: defines Line2D class for drawing lines and markers patches: defines classes for drawing polygons text: defines Text, TextWithDash, and Annotate classes image: defines AxesImage and FigureImage classes collections: classes for efficient drawing of groups of lines or polygons colors: classes for interpreting color specifications and for making colormaps cm: colormaps and the ScalarMappable mixin class for providing color mapping functionality to other classes ticker: classes for calculating tick mark locations and for formatting tick labels backends: a subpackage with modules for various gui libraries and output formats The base matplotlib namespace includes: rcParams: a dictionary of default configuration settings. It is initialized by code which may be overridded by a matplotlibrc file. rc(): a function for setting groups of rcParams values use(): a function for setting the matplotlib backend. If used, this function must be called immediately after importing matplotlib for the first time. In particular, it must be called *before* importing pylab (if pylab is imported). matplotlib is written by John D. Hunter (jdh2358 at gmail.com and a host of others).
requires swig cvs as of 2005-02-24
You will need to have freetype, libpng and zlib installed to compile matplotlib, inlcuding the *-devel versions of these libraries if you are using a package manager like RPM or debian. The matplotlib build options can be modified with a setup.cfg file. See setup.cfg.template for more information.
Poor man's setuptools script...
Some helper functions for building the C extensions you may need to edit basedir to point to the default location of your required libs, eg, png, z, freetype DARWIN I have installed all of the backends on OSX. Tk: If you want to install TkAgg, I recommend the "batteries included" binary build of Tcl/Tk at http://www.apple.com/downloads/macosx/unix_open_source/tcltkaqua.html GTK: I installed GTK from src as described at http://www.macgimp.org/index.php?topic=gtk. There are several packages, but all configure/make/make install w/o problem. In addition to the packages listed there, You will also need libpng, libjpeg, and libtiff if you want output to these formats from GTK. WIN32 - MINGW If you are sufficiently masochistic that you want to build this yourself, download the win32_static dir from http://matplotlib.sourceforge.net/win32_static.tar.gz and see the README file in that dir > python setup.py build --compiler=mingw32 bdist_wininst > build23.out NOTE, if you are building on python24 on win32, see http://mail.python.org/pipermail/python-list/2004-December/254826.html WIN32 - VISUAL STUDIO 7.1 (2003) This build is similar to the mingw. Download the visual studio static dependencies from http://matplotlib.sourceforge.net/win32_static_vs.tar.gz and see the README in that dir > python setup.py build bdist_wininst
|string||__date__ = '$Date: 2008-01-06 12:10:34 -0500 (Sun, 6 Jan 2008) $'|
|string||__revision__ = '$Revision: 4802 $'|
|string||__version__ = '0.91.2'|
|_havemath = _python23|
|int||_python23 = 2|
|tuple||get_configdir = verbose.wrap('CONFIGDIR=%s', _get_configdir, always=False)|
|tuple||get_home = verbose.wrap('$HOME=%s', _get_home, always=False)|
|NEWCONFIG = False|
|tuple||rcParams = rc_params()|