diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000000..176a458f94e0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..6680e577eb15 --- /dev/null +++ b/.gitignore @@ -0,0 +1,76 @@ +# Editor temporary/working/backup files # +######################################### +.#* +[#]*# +*~ +*$ +*.bak +*.diff +*.org +.project +*.rej +.settings/ +.*.sw[nop] +.sw[nop] +*.tmp + +# Compiled source # +################### +*.a +*.com +*.class +*.dll +*.exe +*.o +*.py[ocd] +*.so + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.bz2 +*.bzip2 +*.dmg +*.iso +*.jar +*.rar +*.tar +*.tbz2 +*.tgz +*.zip + +# Python files # +################ +# setup.py working directory +build +# sphinx build directory +_build +# setup.py dist directory +dist +doc/build +doc/cdoc/build +# Egg metadata +*.egg-info +# The shelf plugin uses this dir +./.shelf + +# Logs and databases # +###################### +*.log +*.sql +*.sqlite + +# OS generated files # +###################### +.gdb_history +.DS_Store? +ehthumbs.db +Icon? +Thumbs.db + +# Things specific to this project # +################################### +lib/matplotlib/mpl-data/matplotlib.conf +lib/matplotlib/mpl-data/matplotlibrc diff --git a/doc/devel/add_new_projection.rst b/doc/devel/add_new_projection.rst index 2a7943010800..5efbead7fc40 100644 --- a/doc/devel/add_new_projection.rst +++ b/doc/devel/add_new_projection.rst @@ -1,134 +1,134 @@ -.. _adding-new-scales: - -*********************************************** -Adding new scales and projections to matplotlib -*********************************************** - -.. ::author Michael Droettboom - -Matplotlib supports the addition of custom procedures that transform -the data before it is displayed. - -There is an important distinction between two kinds of -transformations. Separable transformations, working on a single -dimension, are called "scales", and non-separable transformations, -that handle data in two or more dimensions at a time, are called -"projections". - -From the user's perspective, the scale of a plot can be set with -:meth:`~matplotlib.axes.Axes.set_xscale` and -:meth:`~matplotlib.axes.Axes.set_xscale`. Projections can be chosen -using the ``projection`` keyword argument to the -:func:`~matplotlib.pylab.plot` or :func:`~matplotlib.pylab.subplot` -functions, e.g.:: - - plot(x, y, projection="custom") - -This document is intended for developers and advanced users who need -to create new scales and projections for matplotlib. The necessary -code for scales and projections can be included anywhere: directly -within a plot script, in third-party code, or in the matplotlib source -tree itself. - -.. _creating-new-scale: - -Creating a new scale -==================== - -Adding a new scale consists of defining a subclass of -:class:`matplotlib.scale.ScaleBase`, that includes the following -elements: - - - A transformation from data coordinates into display coordinates. - - - An inverse of that transformation. This is used, for example, to - convert mouse positions from screen space back into data space. - - - A function to limit the range of the axis to acceptable values - (``limit_range_for_scale()``). A log scale, for instance, would - prevent the range from including values less than or equal to - zero. - - - Locators (major and minor) that determine where to place ticks in - the plot, and optionally, how to adjust the limits of the plot to - some "good" values. Unlike ``limit_range_for_scale()``, which is - always enforced, the range setting here is only used when - automatically setting the range of the plot. - - - Formatters (major and minor) that specify how the tick labels - should be drawn. - -Once the class is defined, it must be registered with matplotlib so -that the user can select it. - -A full-fledged and heavily annotated example is in -:file:`examples/api/custom_scale_example.py`. There are also some classes -in :mod:`matplotlib.scale` that may be used as starting points. - - -.. _creating-new-projection: - -Creating a new projection -========================= - -Adding a new projection consists of defining a subclass of -:class:`matplotlib.axes.Axes`, that includes the following elements: - - - A transformation from data coordinates into display coordinates. - - - An inverse of that transformation. This is used, for example, to - convert mouse positions from screen space back into data space. - - - Transformations for the gridlines, ticks and ticklabels. Custom - projections will often need to place these elements in special - locations, and matplotlib has a facility to help with doing so. - - - Setting up default values (overriding - :meth:`~matplotlib.axes.Axes.cla`), since the defaults for a - rectilinear axes may not be appropriate. - - - Defining the shape of the axes, for example, an elliptical axes, - that will be used to draw the background of the plot and for - clipping any data elements. - - - Defining custom locators and formatters for the projection. For - example, in a geographic projection, it may be more convenient to - display the grid in degrees, even if the data is in radians. - - - Set up interactive panning and zooming. This is left as an - "advanced" feature left to the reader, but there is an example of - this for polar plots in :mod:`matplotlib.projections.polar`. - - - Any additional methods for additional convenience or features. - -Once the class is defined, it must be registered with matplotlib -so that the user can select it. - -A full-fledged and heavily annotated example is in -:file:`examples/api/custom_projection_example.py`. The polar plot -functionality in :mod:`matplotlib.projections.polar` may also be of -interest. - -API documentation -================= - -matplotlib.scale ----------------- - -.. automodule:: matplotlib.scale - :members: - :show-inheritance: - -matplotlib.projections ----------------------- - -.. automodule:: matplotlib.projections - :members: - :show-inheritance: - -matplotlib.projections.polar -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. automodule:: matplotlib.projections.polar - :members: - :show-inheritance: +.. _adding-new-scales: + +*********************************************** +Adding new scales and projections to matplotlib +*********************************************** + +.. ::author Michael Droettboom + +Matplotlib supports the addition of custom procedures that transform +the data before it is displayed. + +There is an important distinction between two kinds of +transformations. Separable transformations, working on a single +dimension, are called "scales", and non-separable transformations, +that handle data in two or more dimensions at a time, are called +"projections". + +From the user's perspective, the scale of a plot can be set with +:meth:`~matplotlib.axes.Axes.set_xscale` and +:meth:`~matplotlib.axes.Axes.set_xscale`. Projections can be chosen +using the ``projection`` keyword argument to the +:func:`~matplotlib.pylab.plot` or :func:`~matplotlib.pylab.subplot` +functions, e.g.:: + + plot(x, y, projection="custom") + +This document is intended for developers and advanced users who need +to create new scales and projections for matplotlib. The necessary +code for scales and projections can be included anywhere: directly +within a plot script, in third-party code, or in the matplotlib source +tree itself. + +.. _creating-new-scale: + +Creating a new scale +==================== + +Adding a new scale consists of defining a subclass of +:class:`matplotlib.scale.ScaleBase`, that includes the following +elements: + + - A transformation from data coordinates into display coordinates. + + - An inverse of that transformation. This is used, for example, to + convert mouse positions from screen space back into data space. + + - A function to limit the range of the axis to acceptable values + (``limit_range_for_scale()``). A log scale, for instance, would + prevent the range from including values less than or equal to + zero. + + - Locators (major and minor) that determine where to place ticks in + the plot, and optionally, how to adjust the limits of the plot to + some "good" values. Unlike ``limit_range_for_scale()``, which is + always enforced, the range setting here is only used when + automatically setting the range of the plot. + + - Formatters (major and minor) that specify how the tick labels + should be drawn. + +Once the class is defined, it must be registered with matplotlib so +that the user can select it. + +A full-fledged and heavily annotated example is in +:file:`examples/api/custom_scale_example.py`. There are also some classes +in :mod:`matplotlib.scale` that may be used as starting points. + + +.. _creating-new-projection: + +Creating a new projection +========================= + +Adding a new projection consists of defining a subclass of +:class:`matplotlib.axes.Axes`, that includes the following elements: + + - A transformation from data coordinates into display coordinates. + + - An inverse of that transformation. This is used, for example, to + convert mouse positions from screen space back into data space. + + - Transformations for the gridlines, ticks and ticklabels. Custom + projections will often need to place these elements in special + locations, and matplotlib has a facility to help with doing so. + + - Setting up default values (overriding + :meth:`~matplotlib.axes.Axes.cla`), since the defaults for a + rectilinear axes may not be appropriate. + + - Defining the shape of the axes, for example, an elliptical axes, + that will be used to draw the background of the plot and for + clipping any data elements. + + - Defining custom locators and formatters for the projection. For + example, in a geographic projection, it may be more convenient to + display the grid in degrees, even if the data is in radians. + + - Set up interactive panning and zooming. This is left as an + "advanced" feature left to the reader, but there is an example of + this for polar plots in :mod:`matplotlib.projections.polar`. + + - Any additional methods for additional convenience or features. + +Once the class is defined, it must be registered with matplotlib +so that the user can select it. + +A full-fledged and heavily annotated example is in +:file:`examples/api/custom_projection_example.py`. The polar plot +functionality in :mod:`matplotlib.projections.polar` may also be of +interest. + +API documentation +================= + +matplotlib.scale +---------------- + +.. automodule:: matplotlib.scale + :members: + :show-inheritance: + +matplotlib.projections +---------------------- + +.. automodule:: matplotlib.projections + :members: + :show-inheritance: + +matplotlib.projections.polar +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. automodule:: matplotlib.projections.polar + :members: + :show-inheritance: diff --git a/doc/users/artists.rst b/doc/users/artists.rst index 73d7353e8362..d7777cac0019 100644 --- a/doc/users/artists.rst +++ b/doc/users/artists.rst @@ -1,610 +1,610 @@ -.. _artist-tutorial: - -*************** -Artist tutorial -*************** - -There are three layers to the matplotlib API. The -:class:`matplotlib.backend_bases.FigureCanvas` is the area onto which -the figure is drawn, the :class:`matplotlib.backend_bases.Renderer` is -the object which knows how to draw on the -:class:`~matplotlib.backend_bases.FigureCanvas`, and the -:class:`matplotlib.artist.Artist` is the object that knows how to use -a renderer to paint onto the canvas. The -:class:`~matplotlib.backend_bases.FigureCanvas` and -:class:`~matplotlib.backend_bases.Renderer` handle all the details of -talking to user interface toolkits like `wxPython -`_ or drawing languages like PostScript®, and -the ``Artist`` handles all the high level constructs like representing -and laying out the figure, text, and lines. The typical user will -spend 95% of his time working with the ``Artists``. - -There are two types of ``Artists``: primitives and containers. The primitives represent the standard graphical objects we want to paint onto our canvas: :class:`~matplotlib.lines.Line2D`, :class:`~matplotlib.patches.Rectangle`, :class:`~matplotlib.text.Text`, :class:`~matplotlib.image.AxesImage`, etc., and the containers are places to put them (:class:`~matplotlib.axis.Axis`, :class:`~matplotlib.axes.Axes` and :class:`~matplotlib.figure.Figure`). The standard use is to create a :class:`~matplotlib.figure.Figure` instance, use the ``Figure`` to create one or more :class:`~matplotlib.axes.Axes` or :class:`~matplotlib.axes.Subplot` instances, and use the ``Axes`` instance helper methods to create the primitives. In the example below, we create a ``Figure`` instance using :func:`matplotlib.pyplot.figure`, which is a convenience method for instantiating ``Figure`` instances and connecting them with your user interface or drawing toolkit ``FigureCanvas``. As we will discuss below, this is not necessary -- you can work directly with PostScript, PDF Gtk+, or wxPython ``FigureCanvas`` instances, instantiate your ``Figures`` directly and connect them yourselves -- but since we are focusing here on the ``Artist`` API we'll let :mod:`~matplotlib.pyplot` handle some of those details for us:: - - import matplotlib.pyplot as plt - fig = plt.figure() - ax = fig.add_subplot(2,1,1) # two rows, one column, first plot - -The :class:`~matplotlib.axes.Axes` is probably the most important -class in the matplotlib API, and the one you will be working with most -of the time. This is because the ``Axes`` is the plotting area into -which most of the objects go, and the ``Axes`` has many special helper -methods (:meth:`~matplotlib.axes.Axes.plot`, -:meth:`~matplotlib.axes.Axes.text`, -:meth:`~matplotlib.axes.Axes.hist`, -:meth:`~matplotlib.axes.Axes.imshow`) to create the most common -graphics primitives (:class:`~matplotlib.lines.Line2D`, -:class:`~matplotlib.text.Text`, -:class:`~matplotlib.patches.Rectangle`, -:class:`~matplotlib.image.Image`, respectively). These helper methods -will take your data (eg. ``numpy`` arrays and strings) and create -primitive ``Artist`` instances as needed (eg. ``Line2D``), add them to -the relevant containers, and draw them when requested. Most of you -are probably familiar with the :class:`~matplotlib.axes.Subplot`, -which is just a special case of an ``Axes`` that lives on a regular -rows by columns grid of ``Subplot`` instances. If you want to create -an ``Axes`` at an arbitrary location, simply use the -:meth:`~matplotlib.figure.Figure.add_axes` method which takes a list -of ``[left, bottom, width, height]`` values in 0-1 relative figure -coordinates:: - - fig2 = plt.figure() - ax2 = fig2.add_axes([0.15, 0.1, 0.7, 0.3]) - -Continuing with our example:: - - import numpy as np - t = np.arange(0.0, 1.0, 0.01) - s = np.sin(2*np.pi*t) - line, = ax.plot(t, s, color='blue', lw=2) - -In this example, ``ax`` is the ``Axes`` instance created by the -``fig.add_subplot`` call above (remember ``Subplot`` is just a -subclass of ``Axes``) and when you call ``ax.plot``, it creates a -``Line2D`` instance and adds it to the :attr:`Axes.lines -` list. In the interactive `ipython -`_ session below, you can see that the -``Axes.lines`` list is length one and contains the same line that was -returned by the ``line, = ax.plot...`` call: - -.. sourcecode:: ipython - - In [101]: ax.lines[0] - Out[101]: - - In [102]: line - Out[102]: - -If you make subsequent calls to ``ax.plot`` (and the hold state is "on" -which is the default) then additional lines will be added to the list. -You can remove lines later simply by calling the list methods; either -of these will work:: - - del ax.lines[0] - ax.lines.remove(line) # one or the other, not both! - -The Axes also has helper methods to configure and decorate the x-axis -and y-axis tick, tick labels and axis labels:: - - xtext = ax.set_xlabel('my xdata') # returns a Text instance - ytext = ax.set_ylabel('my xdata') - -When you call :meth:`ax.set_xlabel `, -it passes the information on the :class:`~matplotlib.text.Text` -instance of the :class:`~matplotlib.axis.XAxis`. Each ``Axes`` -instance contains an :class:`~matplotlib.axis.XAxis` and a -:class:`~matplotlib.axis.YAxis` instance, which handle the layout and -drawing of the ticks, tick labels and axis labels. - -.. I'm commenting this out, since the new Sphinx cross-references -.. sort of take care of this above - MGD - -.. Here are the most important matplotlib modules that contain the -.. classes referenced above - -.. =============== ================== -.. Artist Module -.. =============== ================== -.. Artist matplotlib.artist -.. Rectangle matplotlib.patches -.. Line2D matplotlib.lines -.. Axes matplotlib.axes -.. XAxis and YAxis matplotlib.axis -.. Figure matplotlib.figure -.. Text matplotlib.text -.. =============== ================== - -Try creating the figure below. - -.. plot:: pyplots/fig_axes_labels_simple.py - -.. _customizing-artists: - -Customizing your objects -======================== - -Every element in the figure is represented by a matplotlib -:class:`~matplotlib.artist.Artist`, and each has an extensive list of -properties to configure its appearance. The figure itself contains a -:class:`~matplotlib.patches.Rectangle` exactly the size of the figure, -which you can use to set the background color and transparency of the -figures. Likewise, each :class:`~matplotlib.axes.Axes` bounding box -(the standard white box with black edges in the typical matplotlib -plot, has a ``Rectangle`` instance that determines the color, -transparency, and other properties of the Axes. These instances are -stored as member variables :attr:`Figure.patch -` and :attr:`Axes.patch -` ("Patch" is a name inherited from -MATLAB™, and is a 2D "patch" of color on the figure, eg. rectangles, -circles and polygons). Every matplotlib ``Artist`` has the following -properties - -========== ====================================================================== -Property Description -========== ====================================================================== -alpha The transparency - a scalar from 0-1 -animated A boolean that is used to facilitate animated drawing -axes The axes that the Artist lives in, possibly None -clip_box The bounding box that clips the Artist -clip_on Whether clipping is enabled -clip_path The path the artist is clipped to -contains A picking function to test whether the artist contains the pick point -figure The figure instance the artist lives in, possibly None -label A text label (eg. for auto-labeling) -picker A python object that controls object picking -transform The transformation -visible A boolean whether the artist should be drawn -zorder A number which determines the drawing order -========== ====================================================================== - -Each of the properties is accessed with an old-fashioned setter or -getter (yes we know this irritates Pythonistas and we plan to support -direct access via properties or traits but it hasn't been done yet). -For example, to multiply the current alpha by a half:: - - a = o.get_alpha() - o.set_alpha(0.5*a) - -If you want to set a number of properties at once, you can also use -the ``set`` method with keyword arguments. For example:: - - o.set(alpha=0.5, zorder=2) - -If you are working interactively at the python shell, a handy way to -inspect the ``Artist`` properties is to use the -:func:`matplotlib.artist.getp` function (simply -:func:`~matplotlib.pylab.getp` in pylab), which lists the properties -and their values. This works for classes derived from ``Artist`` as -well, eg. ``Figure`` and ``Rectangle``. Here are the ``Figure`` rectangle -properties mentioned above: - -.. sourcecode:: ipython - - In [149]: matplotlib.artist.getp(fig.patch) - alpha = 1.0 - animated = False - antialiased or aa = True - axes = None - clip_box = None - clip_on = False - clip_path = None - contains = None - edgecolor or ec = w - facecolor or fc = 0.75 - figure = Figure(8.125x6.125) - fill = 1 - hatch = None - height = 1 - label = - linewidth or lw = 1.0 - picker = None - transform = - verts = ((0, 0), (0, 1), (1, 1), (1, 0)) - visible = True - width = 1 - window_extent = - x = 0 - y = 0 - zorder = 1 - -.. TODO: Update these URLs - -The docstrings for all of the classes also contain the ``Artist`` -properties, so you can consult the interactive "help" or the -:ref:`artist-api` for a listing of properties for a given object. - -.. _object-containers: - -Object containers -================= - - -Now that we know how to inspect and set the properties of a given -object we want to configure, we need to now how to get at that object. -As mentioned in the introduction, there are two kinds of objects: -primitives and containers. The primitives are usually the things you -want to configure (the font of a :class:`~matplotlib.text.Text` -instance, the width of a :class:`~matplotlib.lines.Line2D`) although -the containers also have some properties as well -- for example the -:class:`~matplotlib.axes.Axes` :class:`~matplotlib.artist.Artist` is a -container that contains many of the primitives in your plot, but it -also has properties like the ``xscale`` to control whether the xaxis -is 'linear' or 'log'. In this section we'll review where the various -container objects store the ``Artists`` that you want to get at. - -.. _figure-container: - -Figure container -================ - -The top level container ``Artist`` is the -:class:`matplotlib.figure.Figure`, and it contains everything in the -figure. The background of the figure is a -:class:`~matplotlib.patches.Rectangle` which is stored in -:attr:`Figure.patch `. As -you add subplots (:meth:`~matplotlib.figure.Figure.add_subplot`) and -axes (:meth:`~matplotlib.figure.Figure.add_axes`) to the figure -these will be appended to the :attr:`Figure.axes -`. These are also returned by the -methods that create them: - -.. sourcecode:: ipython - - In [156]: fig = plt.figure() - - In [157]: ax1 = fig.add_subplot(211) - - In [158]: ax2 = fig.add_axes([0.1, 0.1, 0.7, 0.3]) - - In [159]: ax1 - Out[159]: - - In [160]: print fig.axes - [, ] - -Because the figure maintains the concept of the "current axes" (see -:meth:`Figure.gca ` and -:meth:`Figure.sca `) to support the -pylab/pyplot state machine, you should not insert or remove axes -directly from the axes list, but rather use the -:meth:`~matplotlib.figure.Figure.add_subplot` and -:meth:`~matplotlib.figure.Figure.add_axes` methods to insert, and the -:meth:`~matplotlib.figure.Figure.delaxes` method to delete. You are -free however, to iterate over the list of axes or index into it to get -access to ``Axes`` instances you want to customize. Here is an -example which turns all the axes grids on:: - - for ax in fig.axes: - ax.grid(True) - - -The figure also has its own text, lines, patches and images, which you -can use to add primitives directly. The default coordinate system for -the ``Figure`` will simply be in pixels (which is not usually what you -want) but you can control this by setting the transform property of -the ``Artist`` you are adding to the figure. - -.. TODO: Is that still true? - -More useful is "figure coordinates" where (0, 0) is the bottom-left of -the figure and (1, 1) is the top-right of the figure which you can -obtain by setting the ``Artist`` transform to :attr:`fig.transFigure -`: - -.. sourcecode:: ipython - - In [191]: fig = plt.figure() - - In [192]: l1 = matplotlib.lines.Line2D([0, 1], [0, 1], - transform=fig.transFigure, figure=fig) - - In [193]: l2 = matplotlib.lines.Line2D([0, 1], [1, 0], - transform=fig.transFigure, figure=fig) - - In [194]: fig.lines.extend([l1, l2]) - - In [195]: fig.canvas.draw() - -.. plot:: pyplots/fig_x.py - - -Here is a summary of the Artists the figure contains - -.. TODO: Add xrefs to this table - -================ =============================================================== -Figure attribute Description -================ =============================================================== -axes A list of Axes instances (includes Subplot) -patch The Rectangle background -images A list of FigureImages patches - useful for raw pixel display -legends A list of Figure Legend instances (different from Axes.legends) -lines A list of Figure Line2D instances (rarely used, see Axes.lines) -patches A list of Figure patches (rarely used, see Axes.patches) -texts A list Figure Text instances -================ =============================================================== - -.. _axes-container: - -Axes container -============== - -The :class:`matplotlib.axes.Axes` is the center of the matplotlib -universe -- it contains the vast majority of all the ``Artists`` used -in a figure with many helper methods to create and add these -``Artists`` to itself, as well as helper methods to access and -customize the ``Artists`` it contains. Like the -:class:`~matplotlib.figure.Figure`, it contains a -:class:`~matplotlib.patches.Patch` -:attr:`~matplotlib.axes.Axes.patch` which is a -:class:`~matplotlib.patches.Rectangle` for Cartesian coordinates and a -:class:`~matplotlib.patches.Circle` for polar coordinates; this patch -determines the shape, background and border of the plotting region:: - - ax = fig.add_subplot(111) - rect = ax.patch # a Rectangle instance - rect.set_facecolor('green') - -When you call a plotting method, eg. the canonical -:meth:`~matplotlib.axes.Axes.plot` and pass in arrays or lists of -values, the method will create a :meth:`matplotlib.lines.Line2D` -instance, update the line with all the ``Line2D`` properties passed as -keyword arguments, add the line to the :attr:`Axes.lines -` container, and returns it to you: - -.. sourcecode:: ipython - - In [213]: x, y = np.random.rand(2, 100) - - In [214]: line, = ax.plot(x, y, '-', color='blue', linewidth=2) - -``plot`` returns a list of lines because you can pass in multiple x, y -pairs to plot, and we are unpacking the first element of the length -one list into the line variable. The line has been added to the -``Axes.lines`` list: - -.. sourcecode:: ipython - - In [229]: print ax.lines - [] - -Similarly, methods that create patches, like -:meth:`~matplotlib.axes.Axes.bar` creates a list of rectangles, will -add the patches to the :attr:`Axes.patches -` list: - -.. sourcecode:: ipython - - In [233]: n, bins, rectangles = ax.hist(np.random.randn(1000), 50, facecolor='yellow') - - In [234]: rectangles - Out[234]: - - In [235]: print len(ax.patches) - -You should not add objects directly to the ``Axes.lines`` or -``Axes.patches`` lists unless you know exactly what you are doing, -because the ``Axes`` needs to do a few things when it creates and adds -an object. It sets the figure and axes property of the ``Artist``, as -well as the default ``Axes`` transformation (unless a transformation -is set). It also inspects the data contained in the ``Artist`` to -update the data structures controlling auto-scaling, so that the view -limits can be adjusted to contain the plotted data. You can, -nonetheless, create objects yourself and add them directly to the -``Axes`` using helper methods like -:meth:`~matplotlib.axes.Axes.add_line` and -:meth:`~matplotlib.axes.Axes.add_patch`. Here is an annotated -interactive session illustrating what is going on: - -.. sourcecode:: ipython - - In [261]: fig = plt.figure() - - In [262]: ax = fig.add_subplot(111) - - # create a rectangle instance - In [263]: rect = matplotlib.patches.Rectangle( (1,1), width=5, height=12) - - # by default the axes instance is None - In [264]: print rect.get_axes() - None - - # and the transformation instance is set to the "identity transform" - In [265]: print rect.get_transform() - - - # now we add the Rectangle to the Axes - In [266]: ax.add_patch(rect) - - # and notice that the ax.add_patch method has set the axes - # instance - In [267]: print rect.get_axes() - Axes(0.125,0.1;0.775x0.8) - - # and the transformation has been set too - In [268]: print rect.get_transform() - - - # the default axes transformation is ax.transData - In [269]: print ax.transData - - - # notice that the xlimits of the Axes have not been changed - In [270]: print ax.get_xlim() - (0.0, 1.0) - - # but the data limits have been updated to encompass the rectangle - In [271]: print ax.dataLim.bounds - (1.0, 1.0, 5.0, 12.0) - - # we can manually invoke the auto-scaling machinery - In [272]: ax.autoscale_view() - - # and now the xlim are updated to encompass the rectangle - In [273]: print ax.get_xlim() - (1.0, 6.0) - - # we have to manually force a figure draw - In [274]: ax.figure.canvas.draw() - - -There are many, many ``Axes`` helper methods for creating primitive -``Artists`` and adding them to their respective containers. The table -below summarizes a small sampling of them, the kinds of ``Artist`` they -create, and where they store them - -============================== ==================== ======================= -Helper method Artist Container -============================== ==================== ======================= -ax.annotate - text annotations Annotate ax.texts -ax.bar - bar charts Rectangle ax.patches -ax.errorbar - error bar plots Line2D and Rectangle ax.lines and ax.patches -ax.fill - shared area Polygon ax.patches -ax.hist - histograms Rectangle ax.patches -ax.imshow - image data AxesImage ax.images -ax.legend - axes legends Legend ax.legends -ax.plot - xy plots Line2D ax.lines -ax.scatter - scatter charts PolygonCollection ax.collections -ax.text - text Text ax.texts -============================== ==================== ======================= - - -In addition to all of these ``Artists``, the ``Axes`` contains two -important ``Artist`` containers: the :class:`~matplotlib.axis.XAxis` -and :class:`~matplotlib.axis.YAxis`, which handle the drawing of the -ticks and labels. These are stored as instance variables -:attr:`~matplotlib.axes.Axes.xaxis` and -:attr:`~matplotlib.axes.Axes.yaxis`. The ``XAxis`` and ``YAxis`` -containers will be detailed below, but note that the ``Axes`` contains -many helper methods which forward calls on to the -:class:`~matplotlib.axis.Axis` instances so you often do not need to -work with them directly unless you want to. For example, you can set -the font size of the ``XAxis`` ticklabels using the ``Axes`` helper -method:: - - for label in ax.get_xticklabels(): - label.set_color('orange') - -Below is a summary of the Artists that the Axes contains - -============== ====================================== -Axes attribute Description -============== ====================================== -artists A list of Artist instances -patch Rectangle instance for Axes background -collections A list of Collection instances -images A list of AxesImage -legends A list of Legend instances -lines A list of Line2D instances -patches A list of Patch instances -texts A list of Text instances -xaxis matplotlib.axis.XAxis instance -yaxis matplotlib.axis.YAxis instance -============== ====================================== - -.. _axis-container: - -Axis containers -=============== - -The :class:`matplotlib.axis.Axis` instances handle the drawing of the -tick lines, the grid lines, the tick labels and the axis label. You -can configure the left and right ticks separately for the y-axis, and -the upper and lower ticks separately for the x-axis. The ``Axis`` -also stores the data and view intervals used in auto-scaling, panning -and zooming, as well as the :class:`~matplotlib.ticker.Locator` and -:class:`~matplotlib.ticker.Formatter` instances which control where -the ticks are placed and how they are represented as strings. - -Each ``Axis`` object contains a :attr:`~matplotlib.axis.Axis.label` attribute (this is what :mod:`~matplotlib.pylab` modifies in calls to :func:`~matplotlib.pylab.xlabel` and :func:`~matplotlib.pylab.ylabel`) as well as a list of major and minor ticks. The ticks are :class:`~matplotlib.axis.XTick` and :class:`~matplotlib.axis.YTick` instances, which contain the actual line and text primitives that render the ticks and ticklabels. Because the ticks are dynamically created as needed (eg. when panning and zooming), you should access the lists of major and minor ticks through their accessor methods :meth:`~matplotlib.axis.Axis.get_major_ticks` and :meth:`~matplotlib.axis.Axis.get_minor_ticks`. Although the ticks contain all the primitives and will be covered below, the ``Axis`` methods contain accessor methods to return the tick lines, tick labels, tick locations etc.: - -.. sourcecode:: ipython - - In [285]: axis = ax.xaxis - - In [286]: axis.get_ticklocs() - Out[286]: array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.]) - - In [287]: axis.get_ticklabels() - Out[287]: - - # note there are twice as many ticklines as labels because by - # default there are tick lines at the top and bottom but only tick - # labels below the xaxis; this can be customized - In [288]: axis.get_ticklines() - Out[288]: - - # by default you get the major ticks back - In [291]: axis.get_ticklines() - Out[291]: - - # but you can also ask for the minor ticks - In [292]: axis.get_ticklines(minor=True) - Out[292]: - -Here is a summary of some of the useful accessor methods of the ``Axis`` -(these have corresponding setters where useful, such as -set_major_formatter) - -====================== ========================================================= -Accessor method Description -====================== ========================================================= -get_scale The scale of the axis, eg 'log' or 'linear' -get_view_interval The interval instance of the axis view limits -get_data_interval The interval instance of the axis data limits -get_gridlines A list of grid lines for the Axis -get_label The axis label - a Text instance -get_ticklabels A list of Text instances - keyword minor=True|False -get_ticklines A list of Line2D instances - keyword minor=True|False -get_ticklocs A list of Tick locations - keyword minor=True|False -get_major_locator The matplotlib.ticker.Locator instance for major ticks -get_major_formatter The matplotlib.ticker.Formatter instance for major ticks -get_minor_locator The matplotlib.ticker.Locator instance for minor ticks -get_minor_formatter The matplotlib.ticker.Formatter instance for minor ticks -get_major_ticks A list of Tick instances for major ticks -get_minor_ticks A list of Tick instances for minor ticks -grid Turn the grid on or off for the major or minor ticks -====================== ========================================================= - -Here is an example, not recommended for its beauty, which customizes -the axes and tick properties - -.. plot:: pyplots/fig_axes_customize_simple.py - :include-source: - - -.. _tick-container: - -Tick containers -=============== - -The :class:`matplotlib.axis.Tick` is the final container object in our -descent from the :class:`~matplotlib.figure.Figure` to the -:class:`~matplotlib.axes.Axes` to the :class:`~matplotlib.axis.Axis` -to the :class:`~matplotlib.axis.Tick`. The ``Tick`` contains the tick -and grid line instances, as well as the label instances for the upper -and lower ticks. Each of these is accessible directly as an attribute -of the ``Tick``. In addition, there are boolean variables that determine -whether the upper labels and ticks are on for the x-axis and whether -the right labels and ticks are on for the y-axis. - -============== ========================================================== -Tick attribute Description -============== ========================================================== -tick1line Line2D instance -tick2line Line2D instance -gridline Line2D instance -label1 Text instance -label2 Text instance -gridOn boolean which determines whether to draw the tickline -tick1On boolean which determines whether to draw the 1st tickline -tick2On boolean which determines whether to draw the 2nd tickline -label1On boolean which determines whether to draw tick label -label2On boolean which determines whether to draw tick label -============== ========================================================== - -Here is an example which sets the formatter for the right side ticks with -dollar signs and colors them green on the right side of the yaxis - -.. plot:: pyplots/dollar_ticks.py - :include-source: +.. _artist-tutorial: + +*************** +Artist tutorial +*************** + +There are three layers to the matplotlib API. The +:class:`matplotlib.backend_bases.FigureCanvas` is the area onto which +the figure is drawn, the :class:`matplotlib.backend_bases.Renderer` is +the object which knows how to draw on the +:class:`~matplotlib.backend_bases.FigureCanvas`, and the +:class:`matplotlib.artist.Artist` is the object that knows how to use +a renderer to paint onto the canvas. The +:class:`~matplotlib.backend_bases.FigureCanvas` and +:class:`~matplotlib.backend_bases.Renderer` handle all the details of +talking to user interface toolkits like `wxPython +`_ or drawing languages like PostScript®, and +the ``Artist`` handles all the high level constructs like representing +and laying out the figure, text, and lines. The typical user will +spend 95% of his time working with the ``Artists``. + +There are two types of ``Artists``: primitives and containers. The primitives represent the standard graphical objects we want to paint onto our canvas: :class:`~matplotlib.lines.Line2D`, :class:`~matplotlib.patches.Rectangle`, :class:`~matplotlib.text.Text`, :class:`~matplotlib.image.AxesImage`, etc., and the containers are places to put them (:class:`~matplotlib.axis.Axis`, :class:`~matplotlib.axes.Axes` and :class:`~matplotlib.figure.Figure`). The standard use is to create a :class:`~matplotlib.figure.Figure` instance, use the ``Figure`` to create one or more :class:`~matplotlib.axes.Axes` or :class:`~matplotlib.axes.Subplot` instances, and use the ``Axes`` instance helper methods to create the primitives. In the example below, we create a ``Figure`` instance using :func:`matplotlib.pyplot.figure`, which is a convenience method for instantiating ``Figure`` instances and connecting them with your user interface or drawing toolkit ``FigureCanvas``. As we will discuss below, this is not necessary -- you can work directly with PostScript, PDF Gtk+, or wxPython ``FigureCanvas`` instances, instantiate your ``Figures`` directly and connect them yourselves -- but since we are focusing here on the ``Artist`` API we'll let :mod:`~matplotlib.pyplot` handle some of those details for us:: + + import matplotlib.pyplot as plt + fig = plt.figure() + ax = fig.add_subplot(2,1,1) # two rows, one column, first plot + +The :class:`~matplotlib.axes.Axes` is probably the most important +class in the matplotlib API, and the one you will be working with most +of the time. This is because the ``Axes`` is the plotting area into +which most of the objects go, and the ``Axes`` has many special helper +methods (:meth:`~matplotlib.axes.Axes.plot`, +:meth:`~matplotlib.axes.Axes.text`, +:meth:`~matplotlib.axes.Axes.hist`, +:meth:`~matplotlib.axes.Axes.imshow`) to create the most common +graphics primitives (:class:`~matplotlib.lines.Line2D`, +:class:`~matplotlib.text.Text`, +:class:`~matplotlib.patches.Rectangle`, +:class:`~matplotlib.image.Image`, respectively). These helper methods +will take your data (eg. ``numpy`` arrays and strings) and create +primitive ``Artist`` instances as needed (eg. ``Line2D``), add them to +the relevant containers, and draw them when requested. Most of you +are probably familiar with the :class:`~matplotlib.axes.Subplot`, +which is just a special case of an ``Axes`` that lives on a regular +rows by columns grid of ``Subplot`` instances. If you want to create +an ``Axes`` at an arbitrary location, simply use the +:meth:`~matplotlib.figure.Figure.add_axes` method which takes a list +of ``[left, bottom, width, height]`` values in 0-1 relative figure +coordinates:: + + fig2 = plt.figure() + ax2 = fig2.add_axes([0.15, 0.1, 0.7, 0.3]) + +Continuing with our example:: + + import numpy as np + t = np.arange(0.0, 1.0, 0.01) + s = np.sin(2*np.pi*t) + line, = ax.plot(t, s, color='blue', lw=2) + +In this example, ``ax`` is the ``Axes`` instance created by the +``fig.add_subplot`` call above (remember ``Subplot`` is just a +subclass of ``Axes``) and when you call ``ax.plot``, it creates a +``Line2D`` instance and adds it to the :attr:`Axes.lines +` list. In the interactive `ipython +`_ session below, you can see that the +``Axes.lines`` list is length one and contains the same line that was +returned by the ``line, = ax.plot...`` call: + +.. sourcecode:: ipython + + In [101]: ax.lines[0] + Out[101]: + + In [102]: line + Out[102]: + +If you make subsequent calls to ``ax.plot`` (and the hold state is "on" +which is the default) then additional lines will be added to the list. +You can remove lines later simply by calling the list methods; either +of these will work:: + + del ax.lines[0] + ax.lines.remove(line) # one or the other, not both! + +The Axes also has helper methods to configure and decorate the x-axis +and y-axis tick, tick labels and axis labels:: + + xtext = ax.set_xlabel('my xdata') # returns a Text instance + ytext = ax.set_ylabel('my xdata') + +When you call :meth:`ax.set_xlabel `, +it passes the information on the :class:`~matplotlib.text.Text` +instance of the :class:`~matplotlib.axis.XAxis`. Each ``Axes`` +instance contains an :class:`~matplotlib.axis.XAxis` and a +:class:`~matplotlib.axis.YAxis` instance, which handle the layout and +drawing of the ticks, tick labels and axis labels. + +.. I'm commenting this out, since the new Sphinx cross-references +.. sort of take care of this above - MGD + +.. Here are the most important matplotlib modules that contain the +.. classes referenced above + +.. =============== ================== +.. Artist Module +.. =============== ================== +.. Artist matplotlib.artist +.. Rectangle matplotlib.patches +.. Line2D matplotlib.lines +.. Axes matplotlib.axes +.. XAxis and YAxis matplotlib.axis +.. Figure matplotlib.figure +.. Text matplotlib.text +.. =============== ================== + +Try creating the figure below. + +.. plot:: pyplots/fig_axes_labels_simple.py + +.. _customizing-artists: + +Customizing your objects +======================== + +Every element in the figure is represented by a matplotlib +:class:`~matplotlib.artist.Artist`, and each has an extensive list of +properties to configure its appearance. The figure itself contains a +:class:`~matplotlib.patches.Rectangle` exactly the size of the figure, +which you can use to set the background color and transparency of the +figures. Likewise, each :class:`~matplotlib.axes.Axes` bounding box +(the standard white box with black edges in the typical matplotlib +plot, has a ``Rectangle`` instance that determines the color, +transparency, and other properties of the Axes. These instances are +stored as member variables :attr:`Figure.patch +` and :attr:`Axes.patch +` ("Patch" is a name inherited from +MATLAB™, and is a 2D "patch" of color on the figure, eg. rectangles, +circles and polygons). Every matplotlib ``Artist`` has the following +properties + +========== ====================================================================== +Property Description +========== ====================================================================== +alpha The transparency - a scalar from 0-1 +animated A boolean that is used to facilitate animated drawing +axes The axes that the Artist lives in, possibly None +clip_box The bounding box that clips the Artist +clip_on Whether clipping is enabled +clip_path The path the artist is clipped to +contains A picking function to test whether the artist contains the pick point +figure The figure instance the artist lives in, possibly None +label A text label (eg. for auto-labeling) +picker A python object that controls object picking +transform The transformation +visible A boolean whether the artist should be drawn +zorder A number which determines the drawing order +========== ====================================================================== + +Each of the properties is accessed with an old-fashioned setter or +getter (yes we know this irritates Pythonistas and we plan to support +direct access via properties or traits but it hasn't been done yet). +For example, to multiply the current alpha by a half:: + + a = o.get_alpha() + o.set_alpha(0.5*a) + +If you want to set a number of properties at once, you can also use +the ``set`` method with keyword arguments. For example:: + + o.set(alpha=0.5, zorder=2) + +If you are working interactively at the python shell, a handy way to +inspect the ``Artist`` properties is to use the +:func:`matplotlib.artist.getp` function (simply +:func:`~matplotlib.pylab.getp` in pylab), which lists the properties +and their values. This works for classes derived from ``Artist`` as +well, eg. ``Figure`` and ``Rectangle``. Here are the ``Figure`` rectangle +properties mentioned above: + +.. sourcecode:: ipython + + In [149]: matplotlib.artist.getp(fig.patch) + alpha = 1.0 + animated = False + antialiased or aa = True + axes = None + clip_box = None + clip_on = False + clip_path = None + contains = None + edgecolor or ec = w + facecolor or fc = 0.75 + figure = Figure(8.125x6.125) + fill = 1 + hatch = None + height = 1 + label = + linewidth or lw = 1.0 + picker = None + transform = + verts = ((0, 0), (0, 1), (1, 1), (1, 0)) + visible = True + width = 1 + window_extent = + x = 0 + y = 0 + zorder = 1 + +.. TODO: Update these URLs + +The docstrings for all of the classes also contain the ``Artist`` +properties, so you can consult the interactive "help" or the +:ref:`artist-api` for a listing of properties for a given object. + +.. _object-containers: + +Object containers +================= + + +Now that we know how to inspect and set the properties of a given +object we want to configure, we need to now how to get at that object. +As mentioned in the introduction, there are two kinds of objects: +primitives and containers. The primitives are usually the things you +want to configure (the font of a :class:`~matplotlib.text.Text` +instance, the width of a :class:`~matplotlib.lines.Line2D`) although +the containers also have some properties as well -- for example the +:class:`~matplotlib.axes.Axes` :class:`~matplotlib.artist.Artist` is a +container that contains many of the primitives in your plot, but it +also has properties like the ``xscale`` to control whether the xaxis +is 'linear' or 'log'. In this section we'll review where the various +container objects store the ``Artists`` that you want to get at. + +.. _figure-container: + +Figure container +================ + +The top level container ``Artist`` is the +:class:`matplotlib.figure.Figure`, and it contains everything in the +figure. The background of the figure is a +:class:`~matplotlib.patches.Rectangle` which is stored in +:attr:`Figure.patch `. As +you add subplots (:meth:`~matplotlib.figure.Figure.add_subplot`) and +axes (:meth:`~matplotlib.figure.Figure.add_axes`) to the figure +these will be appended to the :attr:`Figure.axes +`. These are also returned by the +methods that create them: + +.. sourcecode:: ipython + + In [156]: fig = plt.figure() + + In [157]: ax1 = fig.add_subplot(211) + + In [158]: ax2 = fig.add_axes([0.1, 0.1, 0.7, 0.3]) + + In [159]: ax1 + Out[159]: + + In [160]: print fig.axes + [, ] + +Because the figure maintains the concept of the "current axes" (see +:meth:`Figure.gca ` and +:meth:`Figure.sca `) to support the +pylab/pyplot state machine, you should not insert or remove axes +directly from the axes list, but rather use the +:meth:`~matplotlib.figure.Figure.add_subplot` and +:meth:`~matplotlib.figure.Figure.add_axes` methods to insert, and the +:meth:`~matplotlib.figure.Figure.delaxes` method to delete. You are +free however, to iterate over the list of axes or index into it to get +access to ``Axes`` instances you want to customize. Here is an +example which turns all the axes grids on:: + + for ax in fig.axes: + ax.grid(True) + + +The figure also has its own text, lines, patches and images, which you +can use to add primitives directly. The default coordinate system for +the ``Figure`` will simply be in pixels (which is not usually what you +want) but you can control this by setting the transform property of +the ``Artist`` you are adding to the figure. + +.. TODO: Is that still true? + +More useful is "figure coordinates" where (0, 0) is the bottom-left of +the figure and (1, 1) is the top-right of the figure which you can +obtain by setting the ``Artist`` transform to :attr:`fig.transFigure +`: + +.. sourcecode:: ipython + + In [191]: fig = plt.figure() + + In [192]: l1 = matplotlib.lines.Line2D([0, 1], [0, 1], + transform=fig.transFigure, figure=fig) + + In [193]: l2 = matplotlib.lines.Line2D([0, 1], [1, 0], + transform=fig.transFigure, figure=fig) + + In [194]: fig.lines.extend([l1, l2]) + + In [195]: fig.canvas.draw() + +.. plot:: pyplots/fig_x.py + + +Here is a summary of the Artists the figure contains + +.. TODO: Add xrefs to this table + +================ =============================================================== +Figure attribute Description +================ =============================================================== +axes A list of Axes instances (includes Subplot) +patch The Rectangle background +images A list of FigureImages patches - useful for raw pixel display +legends A list of Figure Legend instances (different from Axes.legends) +lines A list of Figure Line2D instances (rarely used, see Axes.lines) +patches A list of Figure patches (rarely used, see Axes.patches) +texts A list Figure Text instances +================ =============================================================== + +.. _axes-container: + +Axes container +============== + +The :class:`matplotlib.axes.Axes` is the center of the matplotlib +universe -- it contains the vast majority of all the ``Artists`` used +in a figure with many helper methods to create and add these +``Artists`` to itself, as well as helper methods to access and +customize the ``Artists`` it contains. Like the +:class:`~matplotlib.figure.Figure`, it contains a +:class:`~matplotlib.patches.Patch` +:attr:`~matplotlib.axes.Axes.patch` which is a +:class:`~matplotlib.patches.Rectangle` for Cartesian coordinates and a +:class:`~matplotlib.patches.Circle` for polar coordinates; this patch +determines the shape, background and border of the plotting region:: + + ax = fig.add_subplot(111) + rect = ax.patch # a Rectangle instance + rect.set_facecolor('green') + +When you call a plotting method, eg. the canonical +:meth:`~matplotlib.axes.Axes.plot` and pass in arrays or lists of +values, the method will create a :meth:`matplotlib.lines.Line2D` +instance, update the line with all the ``Line2D`` properties passed as +keyword arguments, add the line to the :attr:`Axes.lines +` container, and returns it to you: + +.. sourcecode:: ipython + + In [213]: x, y = np.random.rand(2, 100) + + In [214]: line, = ax.plot(x, y, '-', color='blue', linewidth=2) + +``plot`` returns a list of lines because you can pass in multiple x, y +pairs to plot, and we are unpacking the first element of the length +one list into the line variable. The line has been added to the +``Axes.lines`` list: + +.. sourcecode:: ipython + + In [229]: print ax.lines + [] + +Similarly, methods that create patches, like +:meth:`~matplotlib.axes.Axes.bar` creates a list of rectangles, will +add the patches to the :attr:`Axes.patches +` list: + +.. sourcecode:: ipython + + In [233]: n, bins, rectangles = ax.hist(np.random.randn(1000), 50, facecolor='yellow') + + In [234]: rectangles + Out[234]: + + In [235]: print len(ax.patches) + +You should not add objects directly to the ``Axes.lines`` or +``Axes.patches`` lists unless you know exactly what you are doing, +because the ``Axes`` needs to do a few things when it creates and adds +an object. It sets the figure and axes property of the ``Artist``, as +well as the default ``Axes`` transformation (unless a transformation +is set). It also inspects the data contained in the ``Artist`` to +update the data structures controlling auto-scaling, so that the view +limits can be adjusted to contain the plotted data. You can, +nonetheless, create objects yourself and add them directly to the +``Axes`` using helper methods like +:meth:`~matplotlib.axes.Axes.add_line` and +:meth:`~matplotlib.axes.Axes.add_patch`. Here is an annotated +interactive session illustrating what is going on: + +.. sourcecode:: ipython + + In [261]: fig = plt.figure() + + In [262]: ax = fig.add_subplot(111) + + # create a rectangle instance + In [263]: rect = matplotlib.patches.Rectangle( (1,1), width=5, height=12) + + # by default the axes instance is None + In [264]: print rect.get_axes() + None + + # and the transformation instance is set to the "identity transform" + In [265]: print rect.get_transform() + + + # now we add the Rectangle to the Axes + In [266]: ax.add_patch(rect) + + # and notice that the ax.add_patch method has set the axes + # instance + In [267]: print rect.get_axes() + Axes(0.125,0.1;0.775x0.8) + + # and the transformation has been set too + In [268]: print rect.get_transform() + + + # the default axes transformation is ax.transData + In [269]: print ax.transData + + + # notice that the xlimits of the Axes have not been changed + In [270]: print ax.get_xlim() + (0.0, 1.0) + + # but the data limits have been updated to encompass the rectangle + In [271]: print ax.dataLim.bounds + (1.0, 1.0, 5.0, 12.0) + + # we can manually invoke the auto-scaling machinery + In [272]: ax.autoscale_view() + + # and now the xlim are updated to encompass the rectangle + In [273]: print ax.get_xlim() + (1.0, 6.0) + + # we have to manually force a figure draw + In [274]: ax.figure.canvas.draw() + + +There are many, many ``Axes`` helper methods for creating primitive +``Artists`` and adding them to their respective containers. The table +below summarizes a small sampling of them, the kinds of ``Artist`` they +create, and where they store them + +============================== ==================== ======================= +Helper method Artist Container +============================== ==================== ======================= +ax.annotate - text annotations Annotate ax.texts +ax.bar - bar charts Rectangle ax.patches +ax.errorbar - error bar plots Line2D and Rectangle ax.lines and ax.patches +ax.fill - shared area Polygon ax.patches +ax.hist - histograms Rectangle ax.patches +ax.imshow - image data AxesImage ax.images +ax.legend - axes legends Legend ax.legends +ax.plot - xy plots Line2D ax.lines +ax.scatter - scatter charts PolygonCollection ax.collections +ax.text - text Text ax.texts +============================== ==================== ======================= + + +In addition to all of these ``Artists``, the ``Axes`` contains two +important ``Artist`` containers: the :class:`~matplotlib.axis.XAxis` +and :class:`~matplotlib.axis.YAxis`, which handle the drawing of the +ticks and labels. These are stored as instance variables +:attr:`~matplotlib.axes.Axes.xaxis` and +:attr:`~matplotlib.axes.Axes.yaxis`. The ``XAxis`` and ``YAxis`` +containers will be detailed below, but note that the ``Axes`` contains +many helper methods which forward calls on to the +:class:`~matplotlib.axis.Axis` instances so you often do not need to +work with them directly unless you want to. For example, you can set +the font size of the ``XAxis`` ticklabels using the ``Axes`` helper +method:: + + for label in ax.get_xticklabels(): + label.set_color('orange') + +Below is a summary of the Artists that the Axes contains + +============== ====================================== +Axes attribute Description +============== ====================================== +artists A list of Artist instances +patch Rectangle instance for Axes background +collections A list of Collection instances +images A list of AxesImage +legends A list of Legend instances +lines A list of Line2D instances +patches A list of Patch instances +texts A list of Text instances +xaxis matplotlib.axis.XAxis instance +yaxis matplotlib.axis.YAxis instance +============== ====================================== + +.. _axis-container: + +Axis containers +=============== + +The :class:`matplotlib.axis.Axis` instances handle the drawing of the +tick lines, the grid lines, the tick labels and the axis label. You +can configure the left and right ticks separately for the y-axis, and +the upper and lower ticks separately for the x-axis. The ``Axis`` +also stores the data and view intervals used in auto-scaling, panning +and zooming, as well as the :class:`~matplotlib.ticker.Locator` and +:class:`~matplotlib.ticker.Formatter` instances which control where +the ticks are placed and how they are represented as strings. + +Each ``Axis`` object contains a :attr:`~matplotlib.axis.Axis.label` attribute (this is what :mod:`~matplotlib.pylab` modifies in calls to :func:`~matplotlib.pylab.xlabel` and :func:`~matplotlib.pylab.ylabel`) as well as a list of major and minor ticks. The ticks are :class:`~matplotlib.axis.XTick` and :class:`~matplotlib.axis.YTick` instances, which contain the actual line and text primitives that render the ticks and ticklabels. Because the ticks are dynamically created as needed (eg. when panning and zooming), you should access the lists of major and minor ticks through their accessor methods :meth:`~matplotlib.axis.Axis.get_major_ticks` and :meth:`~matplotlib.axis.Axis.get_minor_ticks`. Although the ticks contain all the primitives and will be covered below, the ``Axis`` methods contain accessor methods to return the tick lines, tick labels, tick locations etc.: + +.. sourcecode:: ipython + + In [285]: axis = ax.xaxis + + In [286]: axis.get_ticklocs() + Out[286]: array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.]) + + In [287]: axis.get_ticklabels() + Out[287]: + + # note there are twice as many ticklines as labels because by + # default there are tick lines at the top and bottom but only tick + # labels below the xaxis; this can be customized + In [288]: axis.get_ticklines() + Out[288]: + + # by default you get the major ticks back + In [291]: axis.get_ticklines() + Out[291]: + + # but you can also ask for the minor ticks + In [292]: axis.get_ticklines(minor=True) + Out[292]: + +Here is a summary of some of the useful accessor methods of the ``Axis`` +(these have corresponding setters where useful, such as +set_major_formatter) + +====================== ========================================================= +Accessor method Description +====================== ========================================================= +get_scale The scale of the axis, eg 'log' or 'linear' +get_view_interval The interval instance of the axis view limits +get_data_interval The interval instance of the axis data limits +get_gridlines A list of grid lines for the Axis +get_label The axis label - a Text instance +get_ticklabels A list of Text instances - keyword minor=True|False +get_ticklines A list of Line2D instances - keyword minor=True|False +get_ticklocs A list of Tick locations - keyword minor=True|False +get_major_locator The matplotlib.ticker.Locator instance for major ticks +get_major_formatter The matplotlib.ticker.Formatter instance for major ticks +get_minor_locator The matplotlib.ticker.Locator instance for minor ticks +get_minor_formatter The matplotlib.ticker.Formatter instance for minor ticks +get_major_ticks A list of Tick instances for major ticks +get_minor_ticks A list of Tick instances for minor ticks +grid Turn the grid on or off for the major or minor ticks +====================== ========================================================= + +Here is an example, not recommended for its beauty, which customizes +the axes and tick properties + +.. plot:: pyplots/fig_axes_customize_simple.py + :include-source: + + +.. _tick-container: + +Tick containers +=============== + +The :class:`matplotlib.axis.Tick` is the final container object in our +descent from the :class:`~matplotlib.figure.Figure` to the +:class:`~matplotlib.axes.Axes` to the :class:`~matplotlib.axis.Axis` +to the :class:`~matplotlib.axis.Tick`. The ``Tick`` contains the tick +and grid line instances, as well as the label instances for the upper +and lower ticks. Each of these is accessible directly as an attribute +of the ``Tick``. In addition, there are boolean variables that determine +whether the upper labels and ticks are on for the x-axis and whether +the right labels and ticks are on for the y-axis. + +============== ========================================================== +Tick attribute Description +============== ========================================================== +tick1line Line2D instance +tick2line Line2D instance +gridline Line2D instance +label1 Text instance +label2 Text instance +gridOn boolean which determines whether to draw the tickline +tick1On boolean which determines whether to draw the 1st tickline +tick2On boolean which determines whether to draw the 2nd tickline +label1On boolean which determines whether to draw tick label +label2On boolean which determines whether to draw tick label +============== ========================================================== + +Here is an example which sets the formatter for the right side ticks with +dollar signs and colors them green on the right side of the yaxis + +.. plot:: pyplots/dollar_ticks.py + :include-source: diff --git a/examples/api/font_family_rc.py b/examples/api/font_family_rc.py index 6c096818d808..d379e3163471 100644 --- a/examples/api/font_family_rc.py +++ b/examples/api/font_family_rc.py @@ -1,31 +1,31 @@ -""" -You can explicitly set which font family is picked up for a given font -style (eg 'serif', 'sans-serif', or 'monospace'). - -In the example below, we only allow one font family (Tahoma) for the -san-serif font style. You the default family with the font.family rc -param, eg:: - - rcParams['font.family'] = 'sans-serif' - -and for the font.family you set a list of font styles to try to find -in order:: - - rcParams['font.sans-serif'] = ['Tahoma', 'Bitstream Vera Sans', 'Lucida Grande', 'Verdana'] - -""" - -# -*- noplot -*- - -from matplotlib import rcParams -rcParams['font.family'] = 'sans-serif' -rcParams['font.sans-serif'] = ['Tahoma'] -import matplotlib.pyplot as plt - -fig = plt.figure() -ax = fig.add_subplot(111) -ax.plot([1,2,3], label='test') - -ax.legend() -plt.show() - +""" +You can explicitly set which font family is picked up for a given font +style (eg 'serif', 'sans-serif', or 'monospace'). + +In the example below, we only allow one font family (Tahoma) for the +san-serif font style. You the default family with the font.family rc +param, eg:: + + rcParams['font.family'] = 'sans-serif' + +and for the font.family you set a list of font styles to try to find +in order:: + + rcParams['font.sans-serif'] = ['Tahoma', 'Bitstream Vera Sans', 'Lucida Grande', 'Verdana'] + +""" + +# -*- noplot -*- + +from matplotlib import rcParams +rcParams['font.family'] = 'sans-serif' +rcParams['font.sans-serif'] = ['Tahoma'] +import matplotlib.pyplot as plt + +fig = plt.figure() +ax = fig.add_subplot(111) +ax.plot([1,2,3], label='test') + +ax.legend() +plt.show() + diff --git a/examples/api/font_file.py b/examples/api/font_file.py index 489862f1d34e..ced762d2edbe 100644 --- a/examples/api/font_file.py +++ b/examples/api/font_file.py @@ -1,19 +1,19 @@ -# -*- noplot -*- -""" -Although it is usually not a good idea to explicitly point to a single -ttf file for a font instance, you can do so using the -font_manager.FontProperties fname argument (for a more flexible -solution, see the font_fmaily_rc.py and fonts_demo.py examples). -""" -import matplotlib.font_manager as fm - -import matplotlib.pyplot as plt - -fig = plt.figure() -ax = fig.add_subplot(111) -ax.plot([1,2,3]) - -prop = fm.FontProperties(fname='/Library/Fonts/Tahoma.ttf') -ax.set_title('this is a special font', fontproperties=prop) -plt.show() - +# -*- noplot -*- +""" +Although it is usually not a good idea to explicitly point to a single +ttf file for a font instance, you can do so using the +font_manager.FontProperties fname argument (for a more flexible +solution, see the font_fmaily_rc.py and fonts_demo.py examples). +""" +import matplotlib.font_manager as fm + +import matplotlib.pyplot as plt + +fig = plt.figure() +ax = fig.add_subplot(111) +ax.plot([1,2,3]) + +prop = fm.FontProperties(fname='/Library/Fonts/Tahoma.ttf') +ax.set_title('this is a special font', fontproperties=prop) +plt.show() + diff --git a/examples/data/demodata.csv b/examples/data/demodata.csv index d9656f9da605..c167c4c73479 100644 --- a/examples/data/demodata.csv +++ b/examples/data/demodata.csv @@ -1,11 +1,11 @@ -clientid,date,weekdays,gains,prices,up -0,2008-04-30,Wed,-0.52458192906686452,7791404.0091921333,False -1,2008-05-01,Thu,0.076191536201738269,3167180.7366340165,True -2,2008-05-02,Fri,-0.86850970062880861,9589766.9613829032,False -3,2008-05-03,Sat,-0.42701083852713395,8949415.1867596991,False -4,2008-05-04,Sun,0.2532553652693274,937163.44375252665,True -5,2008-05-05,Mon,-0.68151636911081892,949579.88022264629,False -6,2008-05-06,Tue,0.0071911579626532168,7268426.906552773,True -7,2008-05-07,Wed,0.67449747200412147,7517014.782897247,True -8,2008-05-08,Thu,-1.1841008656818983,1920959.5423492221,False -9,2008-05-09,Fri,-1.5803692595811152,8456240.6198725495,False +clientid,date,weekdays,gains,prices,up +0,2008-04-30,Wed,-0.52458192906686452,7791404.0091921333,False +1,2008-05-01,Thu,0.076191536201738269,3167180.7366340165,True +2,2008-05-02,Fri,-0.86850970062880861,9589766.9613829032,False +3,2008-05-03,Sat,-0.42701083852713395,8949415.1867596991,False +4,2008-05-04,Sun,0.2532553652693274,937163.44375252665,True +5,2008-05-05,Mon,-0.68151636911081892,949579.88022264629,False +6,2008-05-06,Tue,0.0071911579626532168,7268426.906552773,True +7,2008-05-07,Wed,0.67449747200412147,7517014.782897247,True +8,2008-05-08,Thu,-1.1841008656818983,1920959.5423492221,False +9,2008-05-09,Fri,-1.5803692595811152,8456240.6198725495,False diff --git a/lib/matplotlib/mpl-data/images/stock_close.xpm b/lib/matplotlib/mpl-data/images/stock_close.xpm index 4ae0b95b02c9..005ce14dbf37 100644 --- a/lib/matplotlib/mpl-data/images/stock_close.xpm +++ b/lib/matplotlib/mpl-data/images/stock_close.xpm @@ -1,21 +1,21 @@ -/* XPM */ -static char * stock_close_xpm[] = { -"16 16 2 1", -" g None", -". g #000000", -" ", -" ", -" . . ", -" . ... ", -" .. .... ", -" .. ... ", -" ..... ", -" ... ", -" ..... ", -" ....... ", -" ... .... ", -" ... .... ", -" ... .. ", -" ", -" ", -" "}; +/* XPM */ +static char * stock_close_xpm[] = { +"16 16 2 1", +" g None", +". g #000000", +" ", +" ", +" . . ", +" . ... ", +" .. .... ", +" .. ... ", +" ..... ", +" ... ", +" ..... ", +" ....... ", +" ... .... ", +" ... .... ", +" ... .. ", +" ", +" ", +" "}; diff --git a/lib/matplotlib/mpl-data/images/stock_down.xpm b/lib/matplotlib/mpl-data/images/stock_down.xpm index a394f91e9de0..26d0c28ab927 100644 --- a/lib/matplotlib/mpl-data/images/stock_down.xpm +++ b/lib/matplotlib/mpl-data/images/stock_down.xpm @@ -1,44 +1,44 @@ -/* XPM */ -static char * stock_down_xpm[] = { -"16 16 25 1", -" c None", -". c #000000", -"+ c #B5C9DC", -"@ c #9BB6D0", -"# c #91B0CC", -"$ c #49749C", -"% c #456F96", -"& c #AFC5DA", -"* c #A0BAD3", -"= c #9EB8D1", -"- c #3F6588", -"; c #375978", -"> c #B2C7DB", -", c #9CB7D1", -"' c #9AB5CF", -") c #B6CADD", -"! c #5B88B2", -"~ c #A4BDD5", -"{ c #2A435B", -"] c #5080AD", -"^ c #97B3CE", -"/ c #080D11", -"( c #5F8BB4", -"_ c #95B2CE", -": c #4C79A3", -" ", -" ", -" ....... ", -" .+@#$%. ", -" .&*=-;. ", -" .>,'-;. ", -" .),'-;. ", -" .)@@-;. ", -" ....)',-;.... ", -" .!=~*,---{. ", -" .],,,--{. ", -" .]^*-{. ", -" /(_{. ", -" .:. ", -" . ", -" "}; +/* XPM */ +static char * stock_down_xpm[] = { +"16 16 25 1", +" c None", +". c #000000", +"+ c #B5C9DC", +"@ c #9BB6D0", +"# c #91B0CC", +"$ c #49749C", +"% c #456F96", +"& c #AFC5DA", +"* c #A0BAD3", +"= c #9EB8D1", +"- c #3F6588", +"; c #375978", +"> c #B2C7DB", +", c #9CB7D1", +"' c #9AB5CF", +") c #B6CADD", +"! c #5B88B2", +"~ c #A4BDD5", +"{ c #2A435B", +"] c #5080AD", +"^ c #97B3CE", +"/ c #080D11", +"( c #5F8BB4", +"_ c #95B2CE", +": c #4C79A3", +" ", +" ", +" ....... ", +" .+@#$%. ", +" .&*=-;. ", +" .>,'-;. ", +" .),'-;. ", +" .)@@-;. ", +" ....)',-;.... ", +" .!=~*,---{. ", +" .],,,--{. ", +" .]^*-{. ", +" /(_{. ", +" .:. ", +" . ", +" "}; diff --git a/lib/matplotlib/mpl-data/images/stock_left.xpm b/lib/matplotlib/mpl-data/images/stock_left.xpm index 1e26e19406c2..503bc36616e2 100644 --- a/lib/matplotlib/mpl-data/images/stock_left.xpm +++ b/lib/matplotlib/mpl-data/images/stock_left.xpm @@ -1,45 +1,45 @@ -/* XPM */ -static char * stock_left_xpm[] = { -"16 16 26 1", -" c None", -". c #000000", -"+ c #C4D4E3", -"@ c #A3BCD4", -"# c #A6BED5", -"$ c #AAC1D7", -"% c #ABC2D8", -"& c #AFC5DA", -"* c #AEC4D9", -"= c #6892B9", -"- c #9CB7D1", -"; c #A4BDD5", -"> c #9FB9D2", -", c #9BB6D0", -"' c #9AB5CF", -") c #49759E", -"! c #1C2D3D", -"~ c #C5D5E4", -"{ c #A0BAD3", -"] c #9EB8D1", -"^ c #4B78A2", -"/ c #2A435B", -"( c #3F6588", -"_ c #34536F", -": c #29425A", -"< c #2D4760", -" ", -" . ", -" .. ", -" .+. ", -" .+@....... ", -" .+#$%&%*@=. ", -" .+-;@>,,>'). ", -" !~>{]]->>>>^. ", -" ./((((((((_. ", -" ./((:::::<. ", -" ./(....... ", -" ./. ", -" .. ", -" . ", -" ", -" "}; +/* XPM */ +static char * stock_left_xpm[] = { +"16 16 26 1", +" c None", +". c #000000", +"+ c #C4D4E3", +"@ c #A3BCD4", +"# c #A6BED5", +"$ c #AAC1D7", +"% c #ABC2D8", +"& c #AFC5DA", +"* c #AEC4D9", +"= c #6892B9", +"- c #9CB7D1", +"; c #A4BDD5", +"> c #9FB9D2", +", c #9BB6D0", +"' c #9AB5CF", +") c #49759E", +"! c #1C2D3D", +"~ c #C5D5E4", +"{ c #A0BAD3", +"] c #9EB8D1", +"^ c #4B78A2", +"/ c #2A435B", +"( c #3F6588", +"_ c #34536F", +": c #29425A", +"< c #2D4760", +" ", +" . ", +" .. ", +" .+. ", +" .+@....... ", +" .+#$%&%*@=. ", +" .+-;@>,,>'). ", +" !~>{]]->>>>^. ", +" ./((((((((_. ", +" ./((:::::<. ", +" ./(....... ", +" ./. ", +" .. ", +" . ", +" ", +" "}; diff --git a/lib/matplotlib/mpl-data/images/stock_refresh.xpm b/lib/matplotlib/mpl-data/images/stock_refresh.xpm index d686de9f2920..1659cff3dd52 100644 --- a/lib/matplotlib/mpl-data/images/stock_refresh.xpm +++ b/lib/matplotlib/mpl-data/images/stock_refresh.xpm @@ -1,35 +1,35 @@ -/* XPM */ -static char * stock_refresh_xpm[] = { -"16 16 16 1", -" c None", -". c #000000", -"+ c #8FA8BE", -"@ c #D5DEE6", -"# c #BBCBD8", -"$ c #A6BACB", -"% c #A2B7C9", -"& c #83A0B8", -"* c #7393AE", -"= c #4F6F8A", -"- c #48667F", -"; c #92ABC0", -"> c #33485A", -", c #22303B", -"' c #7897B1", -") c #4B6A84", -" ", -" . ", -" ..+. ", -" .@#$%. ", -" .&*==-. ", -" .;>.,. ", -" .'. . . ", -" .). .. ", -" .. .@. ", -" . . .=. ", -" .@.>=. ", -" .@===>. ", -" .'=>>. ", -" .'.. ", -" . ", -" "}; +/* XPM */ +static char * stock_refresh_xpm[] = { +"16 16 16 1", +" c None", +". c #000000", +"+ c #8FA8BE", +"@ c #D5DEE6", +"# c #BBCBD8", +"$ c #A6BACB", +"% c #A2B7C9", +"& c #83A0B8", +"* c #7393AE", +"= c #4F6F8A", +"- c #48667F", +"; c #92ABC0", +"> c #33485A", +", c #22303B", +"' c #7897B1", +") c #4B6A84", +" ", +" . ", +" ..+. ", +" .@#$%. ", +" .&*==-. ", +" .;>.,. ", +" .'. . . ", +" .). .. ", +" .. .@. ", +" . . .=. ", +" .@.>=. ", +" .@===>. ", +" .'=>>. ", +" .'.. ", +" . ", +" "}; diff --git a/lib/matplotlib/mpl-data/images/stock_right.xpm b/lib/matplotlib/mpl-data/images/stock_right.xpm index 2f1607d67b3d..f63c1d34051b 100644 --- a/lib/matplotlib/mpl-data/images/stock_right.xpm +++ b/lib/matplotlib/mpl-data/images/stock_right.xpm @@ -1,44 +1,44 @@ -/* XPM */ -static char * stock_right_xpm[] = { -"16 16 25 1", -" c None", -". c #000000", -"+ c #5B88B2", -"@ c #9EB8D1", -"# c #5080AD", -"$ c #B5C9DC", -"% c #AFC5DA", -"& c #B2C7DB", -"* c #B6CADD", -"= c #A4BDD5", -"- c #9CB7D1", -"; c #080D11", -"> c #9BB6D0", -", c #A0BAD3", -"' c #9AB5CF", -") c #97B3CE", -"! c #5F8BB4", -"~ c #91B0CC", -"{ c #95B2CE", -"] c #4C79A3", -"^ c #49749C", -"/ c #3F6588", -"( c #2A435B", -"_ c #456F96", -": c #375978", -" ", -" . ", -" .. ", -" .+. ", -" .......@#. ", -" .$%&***=-#; ", -" .>,-->',-)!. ", -" .~@''>---,{]. ", -" .^////////(. ", -" ._::::://(. ", -" ......./(. ", -" .(. ", -" .. ", -" . ", -" ", -" "}; +/* XPM */ +static char * stock_right_xpm[] = { +"16 16 25 1", +" c None", +". c #000000", +"+ c #5B88B2", +"@ c #9EB8D1", +"# c #5080AD", +"$ c #B5C9DC", +"% c #AFC5DA", +"& c #B2C7DB", +"* c #B6CADD", +"= c #A4BDD5", +"- c #9CB7D1", +"; c #080D11", +"> c #9BB6D0", +", c #A0BAD3", +"' c #9AB5CF", +") c #97B3CE", +"! c #5F8BB4", +"~ c #91B0CC", +"{ c #95B2CE", +"] c #4C79A3", +"^ c #49749C", +"/ c #3F6588", +"( c #2A435B", +"_ c #456F96", +": c #375978", +" ", +" . ", +" .. ", +" .+. ", +" .......@#. ", +" .$%&***=-#; ", +" .>,-->',-)!. ", +" .~@''>---,{]. ", +" .^////////(. ", +" ._::::://(. ", +" ......./(. ", +" .(. ", +" .. ", +" . ", +" ", +" "}; diff --git a/lib/matplotlib/mpl-data/images/stock_save_as.xpm b/lib/matplotlib/mpl-data/images/stock_save_as.xpm index 63f65f797f63..0981c7c57c61 100644 --- a/lib/matplotlib/mpl-data/images/stock_save_as.xpm +++ b/lib/matplotlib/mpl-data/images/stock_save_as.xpm @@ -1,130 +1,130 @@ -/* XPM */ -static char * stock_save_as_xpm[] = { -"16 16 111 2", -" c None", -". c #000000", -"+ c #F7F8FA", -"@ c #CBDDEB", -"# c #C88A80", -"$ c #D18F84", -"% c #CF8D82", -"& c #A49626", -"* c #634A1E", -"= c #A8BBCC", -"- c #BFD5E8", -"; c #DBE7F1", -"> c #8DA9BE", -", c #B7877E", -"' c #C77568", -") c #C77467", -"! c #C57366", -"~ c #FCEB3D", -"{ c #F7B544", -"] c #61522E", -"^ c #72899A", -"/ c #54697C", -"( c #CFE0ED", -"_ c #D7D7D7", -": c #FEFEFE", -"< c #FCFCFC", -"[ c #F9DF39", -"} c #F7B545", -"| c #6C5F34", -"1 c #B4B4B4", -"2 c #84A0B5", -"3 c #4F6475", -"4 c #D6D6D6", -"5 c #F8D837", -"6 c #EFB44D", -"7 c #584D2B", -"8 c #8F8F8F", -"9 c #F1F1F1", -"0 c #819AAE", -"a c #496072", -"b c #FDFDFD", -"c c #F6D236", -"d c #EDA43E", -"e c #584E2B", -"f c #AAAAAA", -"g c #D3D3D3", -"h c #485F71", -"i c #D5D5D5", -"j c #D7AE74", -"k c #61562F", -"l c #737373", -"m c #C5C5C5", -"n c #B0B0B0", -"o c #7F98AC", -"p c #EDEDED", -"q c #4F4115", -"r c #8D8D8D", -"s c #EBEBEB", -"t c #ECECEC", -"u c #ACBDCB", -"v c #6F767D", -"w c #9AA3AC", -"x c #BFCBD6", -"y c #BDC9D4", -"z c #A1B6C4", -"A c #8BA7BC", -"B c #809CB0", -"C c #6C8394", -"D c #7D97AB", -"E c #7D97AC", -"F c #A4ACB8", -"G c #B9B9B9", -"H c #C7C7C7", -"I c #E1E1E1", -"J c #D4D4D4", -"K c #9C9D9D", -"L c #2F4656", -"M c #80868C", -"N c #183042", -"O c #33495A", -"P c #132D3C", -"Q c #586D80", -"R c #97A5B0", -"S c #86A4B9", -"T c #CDCDCD", -"U c #2E4353", -"V c #5A7082", -"W c #BFBFBF", -"X c #112835", -"Y c #9DA9B0", -"Z c #6B7882", -"` c #829DB1", -" . c #CBCBCB", -".. c #E5E5E5", -"+. c #213648", -"@. c #5F7989", -"#. c #C2C2C2", -"$. c #B2B2B2", -"%. c #112C3A", -"&. c #9FA9B0", -"*. c #59636D", -"=. c #A1A1A1", -"-. c #C0C0C0", -";. c #909090", -">. c #868686", -",. c #6E6E6E", -"'. c #7A7A7A", -"). c #2D3949", -"!. c #3E4F5C", -"~. c #80878F", -"{. c #1A3140", -" . . . . . . . . . . . . . . ", -". + @ # $ $ $ $ % . & * . = - . ", -". ; > , ' ) ) ! . ~ { ] . ^ / . ", -". ( > _ : : < . [ } | . 1 2 3 . ", -". ( > _ _ 4 . 5 6 7 . 8 9 0 a . ", -". ( > _ b . c d e . f g 9 0 h . ", -". ( > _ i . j k . l m n 9 o a . ", -". ( > p . q . . r g s s t 0 a . ", -". ( > u . . v w x x x y z 0 a . ", -". ( > A B C 0 0 0 0 D E 0 0 a . ", -". ( > A F G G H I J K L M 0 a . ", -". ( > 2 m m N O i m G P Q R a . ", -". ( S 0 m T U V m m W X V Y a . ", -". Z ` o ...+.@.m #.$.%.V &.a . ", -". . *.3 =.-.;.;.>.,.'.).!.~.{.. ", -" . . . . . . . . . . . . . . "}; +/* XPM */ +static char * stock_save_as_xpm[] = { +"16 16 111 2", +" c None", +". c #000000", +"+ c #F7F8FA", +"@ c #CBDDEB", +"# c #C88A80", +"$ c #D18F84", +"% c #CF8D82", +"& c #A49626", +"* c #634A1E", +"= c #A8BBCC", +"- c #BFD5E8", +"; c #DBE7F1", +"> c #8DA9BE", +", c #B7877E", +"' c #C77568", +") c #C77467", +"! c #C57366", +"~ c #FCEB3D", +"{ c #F7B544", +"] c #61522E", +"^ c #72899A", +"/ c #54697C", +"( c #CFE0ED", +"_ c #D7D7D7", +": c #FEFEFE", +"< c #FCFCFC", +"[ c #F9DF39", +"} c #F7B545", +"| c #6C5F34", +"1 c #B4B4B4", +"2 c #84A0B5", +"3 c #4F6475", +"4 c #D6D6D6", +"5 c #F8D837", +"6 c #EFB44D", +"7 c #584D2B", +"8 c #8F8F8F", +"9 c #F1F1F1", +"0 c #819AAE", +"a c #496072", +"b c #FDFDFD", +"c c #F6D236", +"d c #EDA43E", +"e c #584E2B", +"f c #AAAAAA", +"g c #D3D3D3", +"h c #485F71", +"i c #D5D5D5", +"j c #D7AE74", +"k c #61562F", +"l c #737373", +"m c #C5C5C5", +"n c #B0B0B0", +"o c #7F98AC", +"p c #EDEDED", +"q c #4F4115", +"r c #8D8D8D", +"s c #EBEBEB", +"t c #ECECEC", +"u c #ACBDCB", +"v c #6F767D", +"w c #9AA3AC", +"x c #BFCBD6", +"y c #BDC9D4", +"z c #A1B6C4", +"A c #8BA7BC", +"B c #809CB0", +"C c #6C8394", +"D c #7D97AB", +"E c #7D97AC", +"F c #A4ACB8", +"G c #B9B9B9", +"H c #C7C7C7", +"I c #E1E1E1", +"J c #D4D4D4", +"K c #9C9D9D", +"L c #2F4656", +"M c #80868C", +"N c #183042", +"O c #33495A", +"P c #132D3C", +"Q c #586D80", +"R c #97A5B0", +"S c #86A4B9", +"T c #CDCDCD", +"U c #2E4353", +"V c #5A7082", +"W c #BFBFBF", +"X c #112835", +"Y c #9DA9B0", +"Z c #6B7882", +"` c #829DB1", +" . c #CBCBCB", +".. c #E5E5E5", +"+. c #213648", +"@. c #5F7989", +"#. c #C2C2C2", +"$. c #B2B2B2", +"%. c #112C3A", +"&. c #9FA9B0", +"*. c #59636D", +"=. c #A1A1A1", +"-. c #C0C0C0", +";. c #909090", +">. c #868686", +",. c #6E6E6E", +"'. c #7A7A7A", +"). c #2D3949", +"!. c #3E4F5C", +"~. c #80878F", +"{. c #1A3140", +" . . . . . . . . . . . . . . ", +". + @ # $ $ $ $ % . & * . = - . ", +". ; > , ' ) ) ! . ~ { ] . ^ / . ", +". ( > _ : : < . [ } | . 1 2 3 . ", +". ( > _ _ 4 . 5 6 7 . 8 9 0 a . ", +". ( > _ b . c d e . f g 9 0 h . ", +". ( > _ i . j k . l m n 9 o a . ", +". ( > p . q . . r g s s t 0 a . ", +". ( > u . . v w x x x y z 0 a . ", +". ( > A B C 0 0 0 0 D E 0 0 a . ", +". ( > A F G G H I J K L M 0 a . ", +". ( > 2 m m N O i m G P Q R a . ", +". ( S 0 m T U V m m W X V Y a . ", +". Z ` o ...+.@.m #.$.%.V &.a . ", +". . *.3 =.-.;.;.>.,.'.).!.~.{.. ", +" . . . . . . . . . . . . . . "}; diff --git a/lib/matplotlib/mpl-data/images/stock_up.xpm b/lib/matplotlib/mpl-data/images/stock_up.xpm index 359aed160ad6..994623624c88 100644 --- a/lib/matplotlib/mpl-data/images/stock_up.xpm +++ b/lib/matplotlib/mpl-data/images/stock_up.xpm @@ -1,45 +1,45 @@ -/* XPM */ -static char * stock_up_xpm[] = { -"16 16 26 1", -" c None", -". c #1C2D3D", -"+ c #000000", -"@ c #C5D5E4", -"# c #C4D4E3", -"$ c #9FB9D2", -"% c #2A435B", -"& c #9CB7D1", -"* c #A0BAD3", -"= c #3F6588", -"- c #A6BED5", -"; c #A4BDD5", -"> c #9EB8D1", -", c #A3BCD4", -"' c #AAC1D7", -") c #ABC2D8", -"! c #29425A", -"~ c #AFC5DA", -"{ c #9BB6D0", -"] c #AEC4D9", -"^ c #9AB5CF", -"/ c #6892B9", -"( c #49759E", -"_ c #4B78A2", -": c #34536F", -"< c #2D4760", -" ", -" . ", -" +@+ ", -" +#$%+ ", -" +#&*=%+ ", -" +#-;>==%+ ", -" +#,',>===%+ ", -" ++++)$&=!++++ ", -" +~{$=!+ ", -" +){$=!+ ", -" +]$$=!+ ", -" +,^$=!+ ", -" +/(_:<+ ", -" +++++++ ", -" ", -" "}; +/* XPM */ +static char * stock_up_xpm[] = { +"16 16 26 1", +" c None", +". c #1C2D3D", +"+ c #000000", +"@ c #C5D5E4", +"# c #C4D4E3", +"$ c #9FB9D2", +"% c #2A435B", +"& c #9CB7D1", +"* c #A0BAD3", +"= c #3F6588", +"- c #A6BED5", +"; c #A4BDD5", +"> c #9EB8D1", +", c #A3BCD4", +"' c #AAC1D7", +") c #ABC2D8", +"! c #29425A", +"~ c #AFC5DA", +"{ c #9BB6D0", +"] c #AEC4D9", +"^ c #9AB5CF", +"/ c #6892B9", +"( c #49759E", +"_ c #4B78A2", +": c #34536F", +"< c #2D4760", +" ", +" . ", +" +@+ ", +" +#$%+ ", +" +#&*=%+ ", +" +#-;>==%+ ", +" +#,',>===%+ ", +" ++++)$&=!++++ ", +" +~{$=!+ ", +" +){$=!+ ", +" +]$$=!+ ", +" +,^$=!+ ", +" +/(_:<+ ", +" +++++++ ", +" ", +" "}; diff --git a/lib/matplotlib/mpl-data/images/stock_zoom-in.xpm b/lib/matplotlib/mpl-data/images/stock_zoom-in.xpm index 33b16b674a9b..349e87e73200 100644 --- a/lib/matplotlib/mpl-data/images/stock_zoom-in.xpm +++ b/lib/matplotlib/mpl-data/images/stock_zoom-in.xpm @@ -1,61 +1,61 @@ -/* XPM */ -static char * stock_zoom_in_xpm[] = { -"16 16 42 1", -" c None", -". c #000000", -"+ c #262626", -"@ c #C5C5C5", -"# c #EEEEEE", -"$ c #EDEDED", -"% c #ABABAB", -"& c #464646", -"* c #878787", -"= c #F1F1F1", -"- c #FEFEFE", -"; c #FDFDFD", -"> c #FCFCFC", -", c #EAEAEA", -"' c #707070", -") c #252525", -"! c #282828", -"~ c #FBFBFB", -"{ c #E8E8E8", -"] c #B0B0B0", -"^ c #FFFFFF", -"/ c #050505", -"( c #040404", -"_ c #FAFAFA", -": c #A4A4A4", -"< c #090909", -"[ c #242424", -"} c #E5E5E5", -"| c #E4E4E4", -"1 c #F9F9F9", -"2 c #BABABA", -"3 c #E7E7E7", -"4 c #858585", -"5 c #E3E3E3", -"6 c #6D6D6D", -"7 c #A1A1A1", -"8 c #202020", -"9 c #686868", -"0 c #343434", -"a c #797979", -"b c #3A3A3A", -"c c #1F1F1F", -" .... ", -" .+@#$%&. ", -" .*=--;>,'. ", -" &=--)!;~{& ", -".]--^/(;>_:. ", -".#-//<(([_}. ", -".$;[(../[_|. ", -".%>;;((~_12. ", -" &,~><)_13& ", -" .4{___156. ", -" .&:}|7&.... ", -" .... 88.. ", -" .90.. ", -" .ab..", -" .9c.", -" .. "}; +/* XPM */ +static char * stock_zoom_in_xpm[] = { +"16 16 42 1", +" c None", +". c #000000", +"+ c #262626", +"@ c #C5C5C5", +"# c #EEEEEE", +"$ c #EDEDED", +"% c #ABABAB", +"& c #464646", +"* c #878787", +"= c #F1F1F1", +"- c #FEFEFE", +"; c #FDFDFD", +"> c #FCFCFC", +", c #EAEAEA", +"' c #707070", +") c #252525", +"! c #282828", +"~ c #FBFBFB", +"{ c #E8E8E8", +"] c #B0B0B0", +"^ c #FFFFFF", +"/ c #050505", +"( c #040404", +"_ c #FAFAFA", +": c #A4A4A4", +"< c #090909", +"[ c #242424", +"} c #E5E5E5", +"| c #E4E4E4", +"1 c #F9F9F9", +"2 c #BABABA", +"3 c #E7E7E7", +"4 c #858585", +"5 c #E3E3E3", +"6 c #6D6D6D", +"7 c #A1A1A1", +"8 c #202020", +"9 c #686868", +"0 c #343434", +"a c #797979", +"b c #3A3A3A", +"c c #1F1F1F", +" .... ", +" .+@#$%&. ", +" .*=--;>,'. ", +" &=--)!;~{& ", +".]--^/(;>_:. ", +".#-//<(([_}. ", +".$;[(../[_|. ", +".%>;;((~_12. ", +" &,~><)_13& ", +" .4{___156. ", +" .&:}|7&.... ", +" .... 88.. ", +" .90.. ", +" .ab..", +" .9c.", +" .. "}; diff --git a/lib/matplotlib/mpl-data/images/stock_zoom-out.xpm b/lib/matplotlib/mpl-data/images/stock_zoom-out.xpm index 044355850404..a9d479124a67 100644 --- a/lib/matplotlib/mpl-data/images/stock_zoom-out.xpm +++ b/lib/matplotlib/mpl-data/images/stock_zoom-out.xpm @@ -1,59 +1,59 @@ -/* XPM */ -static char * stock_zoom_out_xpm[] = { -"16 16 40 1", -" c None", -". c #000000", -"+ c #262626", -"@ c #C5C5C5", -"# c #EEEEEE", -"$ c #EDEDED", -"% c #ABABAB", -"& c #464646", -"* c #878787", -"= c #F1F1F1", -"- c #FEFEFE", -"; c #FDFDFD", -"> c #FCFCFC", -", c #EAEAEA", -"' c #707070", -") c #FBFBFB", -"! c #E8E8E8", -"~ c #B0B0B0", -"{ c #FFFFFF", -"] c #FAFAFA", -"^ c #A4A4A4", -"/ c #050505", -"( c #090909", -"_ c #040404", -": c #242424", -"< c #E5E5E5", -"[ c #E4E4E4", -"} c #F9F9F9", -"| c #BABABA", -"1 c #E7E7E7", -"2 c #858585", -"3 c #E3E3E3", -"4 c #6D6D6D", -"5 c #A1A1A1", -"6 c #202020", -"7 c #686868", -"8 c #343434", -"9 c #797979", -"0 c #3A3A3A", -"a c #1F1F1F", -" .... ", -" .+@#$%&. ", -" .*=--;>,'. ", -" &=----;)!& ", -".~--{--;>]^. ", -".#-//(__:]<. ", -".$;:_../:][. ", -".%>;;;>)]}|. ", -" &,)>))]}1& ", -" .2!]]]}34. ", -" .&^<[5&.... ", -" .... 66.. ", -" .78.. ", -" .90..", -" .7a.", -" .. "}; +/* XPM */ +static char * stock_zoom_out_xpm[] = { +"16 16 40 1", +" c None", +". c #000000", +"+ c #262626", +"@ c #C5C5C5", +"# c #EEEEEE", +"$ c #EDEDED", +"% c #ABABAB", +"& c #464646", +"* c #878787", +"= c #F1F1F1", +"- c #FEFEFE", +"; c #FDFDFD", +"> c #FCFCFC", +", c #EAEAEA", +"' c #707070", +") c #FBFBFB", +"! c #E8E8E8", +"~ c #B0B0B0", +"{ c #FFFFFF", +"] c #FAFAFA", +"^ c #A4A4A4", +"/ c #050505", +"( c #090909", +"_ c #040404", +": c #242424", +"< c #E5E5E5", +"[ c #E4E4E4", +"} c #F9F9F9", +"| c #BABABA", +"1 c #E7E7E7", +"2 c #858585", +"3 c #E3E3E3", +"4 c #6D6D6D", +"5 c #A1A1A1", +"6 c #202020", +"7 c #686868", +"8 c #343434", +"9 c #797979", +"0 c #3A3A3A", +"a c #1F1F1F", +" .... ", +" .+@#$%&. ", +" .*=--;>,'. ", +" &=----;)!& ", +".~--{--;>]^. ", +".#-//(__:]<. ", +".$;:_../:][. ", +".%>;;;>)]}|. ", +" &,)>))]}1& ", +" .2!]]]}34. ", +" .&^<[5&.... ", +" .... 66.. ", +" .78.. ", +" .90..", +" .7a.", +" .. "}; diff --git a/release/win32/Makefile b/release/win32/Makefile index 7137143e3cd7..2257b33511b6 100644 --- a/release/win32/Makefile +++ b/release/win32/Makefile @@ -1,112 +1,112 @@ -PYDIR = C:/Python25 -PYTHON = ${PYDIR}/python.exe -SRCDIR = ${PWD} -WINSRCDIR = `${PWD}/data/mingw_path.sh ${PWD}` -ZLIBVERSION = 1.2.3 -PNGVERSION = 1.2.36 -FREETYPEVERSION = 2.3.9 -TCLTKVERSION = 8.5.7 -MPLVERSION = 0.99.0.rc1 - -## You shouldn't need to configure past this point - -CFLAGS = -Os -D_ftime=ftime64 -DPNG_NO_READ_tIME -DPNG_NO_WRITE_tIME - - -PY_INCLUDE = "${WINSRCDIR}\\zlib-${ZLIBVERSION};${WINSRCDIR}/libpng-${PNGVERSION};${WINSRCDIR}/freetype-${FREETYPEVERSION}/include;${WINSRCDIR}/tcl${TCLTKVERSION}/generic;${WINSRCDIR}/tcl${TCLTKVERSION}/win;${WINSRCDIR}/tk${TCLTKVERSION}/generic;${WINSRCDIR}/tk${TCLTKVERSION}/win;${WINSRCDIR}/tk${TCLTKVERSION}/xlib" - -PY_LINKER = "${WINSRCDIR}/zlib-${ZLIBVERSION};${WINSRCDIR}/libpng-${PNGVERSION};${WINSRCDIR}/freetype-${FREETYPEVERSION}" - -clean: - rm -rf zlib-${ZLIBVERSION}.tar.gz libpng-${PNGVERSION}.tar.bz2 \ - freetype-${FREETYPEVERSION}.tar.bz2 \ - tcl${TCLTKVERSION}-src.tar.gz tk${TCLTKVERSION}-src.tar.gz \ - zlib-${ZLIBVERSION} libpng-${PNGVERSION} freetype-${FREETYPEVERSION} \ - tcl${TCLTKVERSION} tk${TCLTKVERSION} \ - matplotlib-${MPLVERSION} *~ - -fetch_deps: - wget http://www.zlib.net/zlib-${ZLIBVERSION}.tar.gz - wget http://prdownloads.sourceforge.net/libpng/libpng-${PNGVERSION}.tar.bz2 - wget http://prdownloads.sourceforge.net/freetype/freetype-2.3.9.tar.bz2 - wget http://prdownloads.sourceforge.net/tcl/tcl${TCLTKVERSION}-src.tar.gz - wget http://prdownloads.sourceforge.net/tcl/tk${TCLTKVERSION}-src.tar.gz - -zlib: - rm -rf zlib-${ZLIBVERSION} - tar xvfz zlib-${ZLIBVERSION}.tar.gz - cd zlib-${ZLIBVERSION} &&\ - export CFLAGS="${CFLAGS}" &&\ - ./configure &&\ - make -j3 - -# for reasons not clear to me, part of png compilation was failing -# because it could not find zlib.h, even with the CFLAGS which point -# to it and even with tryting to pass --includedir to configure. So I -# manually copy the zlib *.h files into the png dir - JDH -png: zlib - rm -rf libpng-${PNGVERSION} - tar xvfj libpng-${PNGVERSION}.tar.bz2 - cd libpng-${PNGVERSION} &&\ - cp ${SRCDIR}/zlib-${ZLIBVERSION}/*.h . && \ - export CFLAGS="${CFLAGS} -I${SRCDIR}/zlib-${ZLIBVERSION}" &&\ - export LDFLAGS="-L${SRCDIR}/zlib-${ZLIBVERSION}" &&\ - ./configure --disable-shared &&\ - make -j3 &&\ - cp .libs/libpng.a . - -freetype: - rm -rf freetype-${FREETYPEVERSION} - tar xvfj freetype-${FREETYPEVERSION}.tar.bz2 - cd freetype-${FREETYPEVERSION} &&\ - GNUMAKE=mingw32-make ./configure --disable-shared &&\ - cp builds/win32/w32-mingw32.mk config.mk &&\ - mingw32-make -j3 &&\ - cp objs/libfreetype.a . - -freetype_hide: - rm -rf freetype-${FREETYPEVERSION} - tar xvfj freetype-${FREETYPEVERSION}.tar.bz2 - cd freetype-${FREETYPEVERSION} &&\ - export CFLAGS=${CFLAGS} &&\ - ./configure --disable-shared &&\ - cp builds/win32/w32-mingw32.mk config.mk &&\ - make -j3 &&\ - cp objs/libfreetype.a . - -tcltk: - rm -rf tcl${TCLTKVERSION} - rm -rf tk${TCLTKVERSION} - tar xvfz tcl${TCLTKVERSION}-src.tar.gz - tar xvfz tk${TCLTKVERSION}-src.tar.gz - -dependencies: png freetype tcltk - -installers: - rm -rf matplotlib-${MPLVERSION} - tar xvzf matplotlib-${MPLVERSION}.tar.gz - cd matplotlib-${MPLVERSION} &&\ - rm -rf build &&\ - cp ../data/setup*.* . &&\ - export CFLAGS="${CFLAGS}" &&\ - ${PYTHON} setupwin.py build_ext -c mingw32 -I ${PY_INCLUDE} -L ${PY_LINKER} bdist_wininst &&\ - ${PYTHON} setupwinegg.py build_ext -c mingw32 -I ${PY_INCLUDE} -L ${PY_LINKER} bdist_egg - - -inplace: - #rm -rf matplotlib-${MPLVERSION} - #tar xvzf matplotlib-${MPLVERSION}.tar.gz - cd matplotlib-${MPLVERSION} &&\ - rm -rf build lib/matplotlib/*.pyd lib/matplotlib/*.pyc lib/matplotlib/backends/*.pyd lib/matplotlib/backends/*.pyc &&\ - cp ../data/setup*.* . &&\ - ${PYTHON} setup.py build_ext -c mingw32 -I ${PY_INCLUDE} -L ${PY_LINKER} --inplace - cd matplotlib-${MPLVERSION}/lib &&\ - ${PYTHON} -c 'import matplotlib; matplotlib.use("Agg"); from pylab import *; print matplotlib.__file__; plot([1,2,3]); savefig("test.png")' - -test_png: - ${PYTHON} -c 'import matplotlib; matplotlib.use("Agg"); from pylab import *; print matplotlib.__file__; plot([1,2,3]); savefig("test.png")' - -test_plot: - ${PYTHON} -c 'import matplotlib; from pylab import *; print matplotlib.__file__; plot([1,2,3]); show()' - -all: fetch_deps dependencies installers +PYDIR = C:/Python25 +PYTHON = ${PYDIR}/python.exe +SRCDIR = ${PWD} +WINSRCDIR = `${PWD}/data/mingw_path.sh ${PWD}` +ZLIBVERSION = 1.2.3 +PNGVERSION = 1.2.36 +FREETYPEVERSION = 2.3.9 +TCLTKVERSION = 8.5.7 +MPLVERSION = 0.99.0.rc1 + +## You shouldn't need to configure past this point + +CFLAGS = -Os -D_ftime=ftime64 -DPNG_NO_READ_tIME -DPNG_NO_WRITE_tIME + + +PY_INCLUDE = "${WINSRCDIR}\\zlib-${ZLIBVERSION};${WINSRCDIR}/libpng-${PNGVERSION};${WINSRCDIR}/freetype-${FREETYPEVERSION}/include;${WINSRCDIR}/tcl${TCLTKVERSION}/generic;${WINSRCDIR}/tcl${TCLTKVERSION}/win;${WINSRCDIR}/tk${TCLTKVERSION}/generic;${WINSRCDIR}/tk${TCLTKVERSION}/win;${WINSRCDIR}/tk${TCLTKVERSION}/xlib" + +PY_LINKER = "${WINSRCDIR}/zlib-${ZLIBVERSION};${WINSRCDIR}/libpng-${PNGVERSION};${WINSRCDIR}/freetype-${FREETYPEVERSION}" + +clean: + rm -rf zlib-${ZLIBVERSION}.tar.gz libpng-${PNGVERSION}.tar.bz2 \ + freetype-${FREETYPEVERSION}.tar.bz2 \ + tcl${TCLTKVERSION}-src.tar.gz tk${TCLTKVERSION}-src.tar.gz \ + zlib-${ZLIBVERSION} libpng-${PNGVERSION} freetype-${FREETYPEVERSION} \ + tcl${TCLTKVERSION} tk${TCLTKVERSION} \ + matplotlib-${MPLVERSION} *~ + +fetch_deps: + wget http://www.zlib.net/zlib-${ZLIBVERSION}.tar.gz + wget http://prdownloads.sourceforge.net/libpng/libpng-${PNGVERSION}.tar.bz2 + wget http://prdownloads.sourceforge.net/freetype/freetype-2.3.9.tar.bz2 + wget http://prdownloads.sourceforge.net/tcl/tcl${TCLTKVERSION}-src.tar.gz + wget http://prdownloads.sourceforge.net/tcl/tk${TCLTKVERSION}-src.tar.gz + +zlib: + rm -rf zlib-${ZLIBVERSION} + tar xvfz zlib-${ZLIBVERSION}.tar.gz + cd zlib-${ZLIBVERSION} &&\ + export CFLAGS="${CFLAGS}" &&\ + ./configure &&\ + make -j3 + +# for reasons not clear to me, part of png compilation was failing +# because it could not find zlib.h, even with the CFLAGS which point +# to it and even with tryting to pass --includedir to configure. So I +# manually copy the zlib *.h files into the png dir - JDH +png: zlib + rm -rf libpng-${PNGVERSION} + tar xvfj libpng-${PNGVERSION}.tar.bz2 + cd libpng-${PNGVERSION} &&\ + cp ${SRCDIR}/zlib-${ZLIBVERSION}/*.h . && \ + export CFLAGS="${CFLAGS} -I${SRCDIR}/zlib-${ZLIBVERSION}" &&\ + export LDFLAGS="-L${SRCDIR}/zlib-${ZLIBVERSION}" &&\ + ./configure --disable-shared &&\ + make -j3 &&\ + cp .libs/libpng.a . + +freetype: + rm -rf freetype-${FREETYPEVERSION} + tar xvfj freetype-${FREETYPEVERSION}.tar.bz2 + cd freetype-${FREETYPEVERSION} &&\ + GNUMAKE=mingw32-make ./configure --disable-shared &&\ + cp builds/win32/w32-mingw32.mk config.mk &&\ + mingw32-make -j3 &&\ + cp objs/libfreetype.a . + +freetype_hide: + rm -rf freetype-${FREETYPEVERSION} + tar xvfj freetype-${FREETYPEVERSION}.tar.bz2 + cd freetype-${FREETYPEVERSION} &&\ + export CFLAGS=${CFLAGS} &&\ + ./configure --disable-shared &&\ + cp builds/win32/w32-mingw32.mk config.mk &&\ + make -j3 &&\ + cp objs/libfreetype.a . + +tcltk: + rm -rf tcl${TCLTKVERSION} + rm -rf tk${TCLTKVERSION} + tar xvfz tcl${TCLTKVERSION}-src.tar.gz + tar xvfz tk${TCLTKVERSION}-src.tar.gz + +dependencies: png freetype tcltk + +installers: + rm -rf matplotlib-${MPLVERSION} + tar xvzf matplotlib-${MPLVERSION}.tar.gz + cd matplotlib-${MPLVERSION} &&\ + rm -rf build &&\ + cp ../data/setup*.* . &&\ + export CFLAGS="${CFLAGS}" &&\ + ${PYTHON} setupwin.py build_ext -c mingw32 -I ${PY_INCLUDE} -L ${PY_LINKER} bdist_wininst &&\ + ${PYTHON} setupwinegg.py build_ext -c mingw32 -I ${PY_INCLUDE} -L ${PY_LINKER} bdist_egg + + +inplace: + #rm -rf matplotlib-${MPLVERSION} + #tar xvzf matplotlib-${MPLVERSION}.tar.gz + cd matplotlib-${MPLVERSION} &&\ + rm -rf build lib/matplotlib/*.pyd lib/matplotlib/*.pyc lib/matplotlib/backends/*.pyd lib/matplotlib/backends/*.pyc &&\ + cp ../data/setup*.* . &&\ + ${PYTHON} setup.py build_ext -c mingw32 -I ${PY_INCLUDE} -L ${PY_LINKER} --inplace + cd matplotlib-${MPLVERSION}/lib &&\ + ${PYTHON} -c 'import matplotlib; matplotlib.use("Agg"); from pylab import *; print matplotlib.__file__; plot([1,2,3]); savefig("test.png")' + +test_png: + ${PYTHON} -c 'import matplotlib; matplotlib.use("Agg"); from pylab import *; print matplotlib.__file__; plot([1,2,3]); savefig("test.png")' + +test_plot: + ${PYTHON} -c 'import matplotlib; from pylab import *; print matplotlib.__file__; plot([1,2,3]); show()' + +all: fetch_deps dependencies installers diff --git a/release/win32/data/setup.cfg b/release/win32/data/setup.cfg index 080d183c9d0c..3f2b860597de 100644 --- a/release/win32/data/setup.cfg +++ b/release/win32/data/setup.cfg @@ -1,79 +1,79 @@ -# Rename this file to setup.cfg to modify matplotlib's -# build options. - -[egg_info] -tag_svn_revision = 0 - -[status] -# To suppress display of the dependencies and their versions -# at the top of the build log, uncomment the following line: -#suppress = True -# -# Uncomment to insert lots of diagnostic prints in extension code -#verbose = True - -[provide_packages] -# By default, matplotlib checks for a few dependencies and -# installs them if missing. This feature can be turned off -# by uncommenting the following lines. Acceptible values are: -# True: install, overwrite an existing installation -# False: do not install -# auto: install only if the package is unavailable. This -# is the default behavior -# -## Date/timezone support: -pytz = True -dateutil = True - - -[gui_support] -# Matplotlib supports multiple GUI toolkits, including Cocoa, -# GTK, Fltk, MacOSX, Qt, Qt4, Tk, and WX. Support for many of -# these toolkits requires AGG, the Anti-Grain Geometry library, -# which is provided by matplotlib and built by default. -# -# Some backends are written in pure Python, and others require -# extension code to be compiled. By default, matplotlib checks -# for these GUI toolkits during installation and, if present, -# compiles the required extensions to support the toolkit. GTK -# support requires the GTK runtime environment and PyGTK. Wx -# support requires wxWidgets and wxPython. Tk support requires -# Tk and Tkinter. The other GUI toolkits do not require any -# extension code, and can be used as long as the libraries are -# installed on your system. -# -# You can uncomment any the following lines if you know you do -# not want to use the GUI toolkit. Acceptible values are: -# True: build the extension. Exits with a warning if the -# required dependencies are not available -# False: do not build the extension -# auto: build if the required dependencies are available, -# otherwise skip silently. This is the default -# behavior -# -gtk = False -gtkagg = False -tkagg = True -wxagg = False -macosx = False - -[rc_options] -# User-configurable options -# -# Default backend, one of: Agg, Cairo, CocoaAgg, GTK, GTKAgg, GTKCairo, -# FltkAgg, MacOSX, Pdf, Ps, QtAgg, Qt4Agg, SVG, TkAgg, WX, WXAgg. -# -# The Agg, Ps, Pdf and SVG backends do not require external -# dependencies. Do not choose GTK, GTKAgg, GTKCairo, MacOSX, TkAgg or WXAgg -# if you have disabled the relevent extension modules. Agg will be used -# by default. -# -backend = TkAgg -# -# The numerix module was historically used to provide -# compatibility between the Numeric, numarray, and NumPy array -# packages. Now that NumPy has emerge as the universal array -# package for python, numerix is not really necessary and is -# maintained to provide backward compatibility. Do not change -# this unless you have a compelling reason to do so. -#numerix = numpy +# Rename this file to setup.cfg to modify matplotlib's +# build options. + +[egg_info] +tag_svn_revision = 0 + +[status] +# To suppress display of the dependencies and their versions +# at the top of the build log, uncomment the following line: +#suppress = True +# +# Uncomment to insert lots of diagnostic prints in extension code +#verbose = True + +[provide_packages] +# By default, matplotlib checks for a few dependencies and +# installs them if missing. This feature can be turned off +# by uncommenting the following lines. Acceptible values are: +# True: install, overwrite an existing installation +# False: do not install +# auto: install only if the package is unavailable. This +# is the default behavior +# +## Date/timezone support: +pytz = True +dateutil = True + + +[gui_support] +# Matplotlib supports multiple GUI toolkits, including Cocoa, +# GTK, Fltk, MacOSX, Qt, Qt4, Tk, and WX. Support for many of +# these toolkits requires AGG, the Anti-Grain Geometry library, +# which is provided by matplotlib and built by default. +# +# Some backends are written in pure Python, and others require +# extension code to be compiled. By default, matplotlib checks +# for these GUI toolkits during installation and, if present, +# compiles the required extensions to support the toolkit. GTK +# support requires the GTK runtime environment and PyGTK. Wx +# support requires wxWidgets and wxPython. Tk support requires +# Tk and Tkinter. The other GUI toolkits do not require any +# extension code, and can be used as long as the libraries are +# installed on your system. +# +# You can uncomment any the following lines if you know you do +# not want to use the GUI toolkit. Acceptible values are: +# True: build the extension. Exits with a warning if the +# required dependencies are not available +# False: do not build the extension +# auto: build if the required dependencies are available, +# otherwise skip silently. This is the default +# behavior +# +gtk = False +gtkagg = False +tkagg = True +wxagg = False +macosx = False + +[rc_options] +# User-configurable options +# +# Default backend, one of: Agg, Cairo, CocoaAgg, GTK, GTKAgg, GTKCairo, +# FltkAgg, MacOSX, Pdf, Ps, QtAgg, Qt4Agg, SVG, TkAgg, WX, WXAgg. +# +# The Agg, Ps, Pdf and SVG backends do not require external +# dependencies. Do not choose GTK, GTKAgg, GTKCairo, MacOSX, TkAgg or WXAgg +# if you have disabled the relevent extension modules. Agg will be used +# by default. +# +backend = TkAgg +# +# The numerix module was historically used to provide +# compatibility between the Numeric, numarray, and NumPy array +# packages. Now that NumPy has emerge as the universal array +# package for python, numerix is not really necessary and is +# maintained to provide backward compatibility. Do not change +# this unless you have a compelling reason to do so. +#numerix = numpy diff --git a/release/win32/data/setupwin.py b/release/win32/data/setupwin.py index d4f6e9f4bc00..85063e8b4795 100644 --- a/release/win32/data/setupwin.py +++ b/release/win32/data/setupwin.py @@ -1,12 +1,12 @@ -from distutils import cygwinccompiler - -try: - # Python 2.6 - # Replace the msvcr func to return an [] - cygwinccompiler.get_msvcr - cygwinccompiler.get_msvcr = lambda: [] - -except AttributeError: - pass - -execfile('setup.py') +from distutils import cygwinccompiler + +try: + # Python 2.6 + # Replace the msvcr func to return an [] + cygwinccompiler.get_msvcr + cygwinccompiler.get_msvcr = lambda: [] + +except AttributeError: + pass + +execfile('setup.py') diff --git a/release/win32/data/setupwinegg.py b/release/win32/data/setupwinegg.py index 3f3313a810b1..384739ad1628 100644 --- a/release/win32/data/setupwinegg.py +++ b/release/win32/data/setupwinegg.py @@ -1,15 +1,15 @@ -from distutils import cygwinccompiler - -try: - # Python 2.6 - # Replace the msvcr func to return an empty list - cygwinccompiler.get_msvcr - cygwinccompiler.get_msvcr = lambda: [] - -except AttributeError: - pass - -from setuptools import setup -execfile('setup.py', - {'additional_params' : - {'namespace_packages' : ['mpl_toolkits']}}) +from distutils import cygwinccompiler + +try: + # Python 2.6 + # Replace the msvcr func to return an empty list + cygwinccompiler.get_msvcr + cygwinccompiler.get_msvcr = lambda: [] + +except AttributeError: + pass + +from setuptools import setup +execfile('setup.py', + {'additional_params' : + {'namespace_packages' : ['mpl_toolkits']}})