From: <jd...@us...> - 2009-08-22 23:26:33
|
Revision: 7524 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7524&view=rev Author: jdh2358 Date: 2009-08-22 23:26:25 +0000 (Sat, 22 Aug 2009) Log Message: ----------- Merged revisions 7489-7490,7498-7502,7506,7517,7519,7521-7523 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_99_maint ........ r7489 | jdh2358 | 2009-08-15 10:40:27 -0700 (Sat, 15 Aug 2009) | 1 line some doc reorg ........ r7490 | jdh2358 | 2009-08-15 10:56:44 -0700 (Sat, 15 Aug 2009) | 1 line added transformations tut, did some reorg ........ r7498 | jdh2358 | 2009-08-17 20:48:21 -0700 (Mon, 17 Aug 2009) | 1 line added path tut ........ r7499 | jdh2358 | 2009-08-17 22:15:21 -0700 (Mon, 17 Aug 2009) | 1 line added looking glass demo ........ r7500 | mdboom | 2009-08-18 07:00:28 -0700 (Tue, 18 Aug 2009) | 2 lines Fix some minor typos in the transforms tutorial ........ r7501 | mdboom | 2009-08-18 07:01:41 -0700 (Tue, 18 Aug 2009) | 2 lines Fix some minor typos in the transforms tutorial ........ r7502 | mdboom | 2009-08-18 07:08:27 -0700 (Tue, 18 Aug 2009) | 2 lines Fix some minor typos in the paths tutorial ........ r7506 | ryanmay | 2009-08-19 00:56:33 -0700 (Wed, 19 Aug 2009) | 1 line Remove calls to np.asarray(). This was breaking the use of masked arrays in calls to set_[x|y]data() and is handled appropriately already by set_data(). ........ r7517 | jdh2358 | 2009-08-21 17:02:15 -0700 (Fri, 21 Aug 2009) | 1 line fixed a fifo bug for the new transforms infrastructure ........ r7519 | jouni | 2009-08-21 23:25:07 -0700 (Fri, 21 Aug 2009) | 2 lines Fix typos found by Marc Desmarais and Nicolas Pinto ........ r7521 | jdh2358 | 2009-08-22 15:50:55 -0700 (Sat, 22 Aug 2009) | 1 line added Ariel's max install patch ........ r7522 | jdh2358 | 2009-08-22 16:19:44 -0700 (Sat, 22 Aug 2009) | 1 line applied Ariel's mlab.cohere_pairs fixes ........ r7523 | jdh2358 | 2009-08-22 16:20:30 -0700 (Sat, 22 Aug 2009) | 1 line fix osx epd formatting bug in rest ........ Modified Paths: -------------- trunk/matplotlib/CXX/IndirectPythonInterface.hxx trunk/matplotlib/agg24/include/agg_basics.h trunk/matplotlib/doc/_templates/indexsidebar.html trunk/matplotlib/doc/_templates/layout.html trunk/matplotlib/doc/faq/installing_faq.rst trunk/matplotlib/doc/users/artists.rst trunk/matplotlib/doc/users/index.rst trunk/matplotlib/doc/users/index_text.rst trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/lines.py trunk/matplotlib/lib/matplotlib/mlab.py Added Paths: ----------- trunk/matplotlib/doc/pyplots/annotate_transform.py trunk/matplotlib/doc/pyplots/compound_path_demo.py trunk/matplotlib/doc/users/annotations_guide.rst trunk/matplotlib/doc/users/annotations_intro.rst trunk/matplotlib/doc/users/legend_guide.rst trunk/matplotlib/doc/users/path_tutorial.rst trunk/matplotlib/doc/users/transforms_tutorial.rst trunk/matplotlib/examples/event_handling/looking_glass.py Removed Paths: ------------- trunk/matplotlib/doc/users/annotations.rst trunk/matplotlib/doc/users/plotting/annotation.rst trunk/matplotlib/doc/users/plotting/legend.rst Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/doc/pyplots/README trunk/matplotlib/doc/sphinxext/gen_gallery.py trunk/matplotlib/doc/sphinxext/gen_rst.py trunk/matplotlib/examples/misc/multiprocess.py trunk/matplotlib/examples/mplot3d/contour3d_demo.py trunk/matplotlib/examples/mplot3d/contourf3d_demo.py trunk/matplotlib/examples/mplot3d/polys3d_demo.py trunk/matplotlib/examples/mplot3d/scatter3d_demo.py trunk/matplotlib/examples/mplot3d/surface3d_demo.py trunk/matplotlib/examples/mplot3d/wire3d_demo.py trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 /branches/v0_99_maint:1-7486 + /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 /branches/v0_99_maint:1-7523 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523 Modified: trunk/matplotlib/CXX/IndirectPythonInterface.hxx =================================================================== --- trunk/matplotlib/CXX/IndirectPythonInterface.hxx 2009-08-22 23:20:30 UTC (rev 7523) +++ trunk/matplotlib/CXX/IndirectPythonInterface.hxx 2009-08-22 23:26:25 UTC (rev 7524) @@ -193,6 +193,6 @@ void _XDECREF( PyObject *op ); char *__Py_PackageContext(); -}; +} #endif // __CXX_INDIRECT_PYTHON_INTERFACE__HXX__ Modified: trunk/matplotlib/agg24/include/agg_basics.h =================================================================== --- trunk/matplotlib/agg24/include/agg_basics.h 2009-08-22 23:20:30 UTC (rev 7523) +++ trunk/matplotlib/agg24/include/agg_basics.h 2009-08-22 23:26:25 UTC (rev 7524) @@ -2,8 +2,8 @@ // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // @@ -25,12 +25,12 @@ #else namespace agg { - // The policy of all AGG containers and memory allocation strategy + // The policy of all AGG containers and memory allocation strategy // in general is that no allocated data requires explicit construction. // It means that the allocator can be really simple; you can even - // replace new/delete to malloc/free. The constructors and destructors - // won't be called in this case, however everything will remain working. - // The second argument of deallocate() is the size of the allocated + // replace new/delete to malloc/free. The constructors and destructors + // won't be called in this case, however everything will remain working. + // The second argument of deallocate() is the size of the allocated // block. You can use this information if you wish. //------------------------------------------------------------pod_allocator template<class T> struct pod_allocator @@ -40,8 +40,8 @@ }; // Single object allocator. It's also can be replaced with your custom - // allocator. The difference is that it can only allocate a single - // object and the constructor and destructor must be called. + // allocator. The difference is that it can only allocate a single + // object and the constructor and destructor must be called. // In AGG there is no need to allocate an array of objects with // calling their constructors (only single ones). So that, if you // replace these new/delete to malloc/free make sure that the in-place @@ -213,23 +213,23 @@ enum cover_scale_e { cover_shift = 8, //----cover_shift - cover_size = 1 << cover_shift, //----cover_size - cover_mask = cover_size - 1, //----cover_mask - cover_none = 0, //----cover_none - cover_full = cover_mask //----cover_full + cover_size = 1 << cover_shift, //----cover_size + cover_mask = cover_size - 1, //----cover_mask + cover_none = 0, //----cover_none + cover_full = cover_mask //----cover_full }; //----------------------------------------------------poly_subpixel_scale_e - // These constants determine the subpixel accuracy, to be more precise, - // the number of bits of the fractional part of the coordinates. + // These constants determine the subpixel accuracy, to be more precise, + // the number of bits of the fractional part of the coordinates. // The possible coordinate capacity in bits can be calculated by formula: // sizeof(int) * 8 - poly_subpixel_shift, i.e, for 32-bit integers and // 8-bits fractional part the capacity is 24 bits. enum poly_subpixel_scale_e { poly_subpixel_shift = 8, //----poly_subpixel_shift - poly_subpixel_scale = 1<<poly_subpixel_shift, //----poly_subpixel_scale - poly_subpixel_mask = poly_subpixel_scale-1, //----poly_subpixel_mask + poly_subpixel_scale = 1<<poly_subpixel_shift, //----poly_subpixel_scale + poly_subpixel_mask = poly_subpixel_scale-1 //----poly_subpixel_mask }; //----------------------------------------------------------filling_rule_e @@ -253,7 +253,7 @@ { return rad * 180.0 / pi; } - + //----------------------------------------------------------------rect_base template<class T> struct rect_base { @@ -265,9 +265,9 @@ rect_base(T x1_, T y1_, T x2_, T y2_) : x1(x1_), y1(y1_), x2(x2_), y2(y2_) {} - void init(T x1_, T y1_, T x2_, T y2_) + void init(T x1_, T y1_, T x2_, T y2_) { - x1 = x1_; y1 = y1_; x2 = x2_; y2 = y2_; + x1 = x1_; y1 = y1_; x2 = x2_; y2 = y2_; } const self_type& normalize() @@ -299,17 +299,17 @@ }; //-----------------------------------------------------intersect_rectangles - template<class Rect> + template<class Rect> inline Rect intersect_rectangles(const Rect& r1, const Rect& r2) { Rect r = r1; - // First process x2,y2 because the other order - // results in Internal Compiler Error under - // Microsoft Visual C++ .NET 2003 69462-335-0000007-18038 in + // First process x2,y2 because the other order + // results in Internal Compiler Error under + // Microsoft Visual C++ .NET 2003 69462-335-0000007-18038 in // case of "Maximize Speed" optimization option. //----------------- - if(r.x2 > r2.x2) r.x2 = r2.x2; + if(r.x2 > r2.x2) r.x2 = r2.x2; if(r.y2 > r2.y2) r.y2 = r2.y2; if(r.x1 < r2.x1) r.x1 = r2.x1; if(r.y1 < r2.y1) r.y1 = r2.y1; @@ -318,7 +318,7 @@ //---------------------------------------------------------unite_rectangles - template<class Rect> + template<class Rect> inline Rect unite_rectangles(const Rect& r1, const Rect& r2) { Rect r = r1; @@ -336,26 +336,26 @@ //---------------------------------------------------------path_commands_e enum path_commands_e { - path_cmd_stop = 0, //----path_cmd_stop - path_cmd_move_to = 1, //----path_cmd_move_to - path_cmd_line_to = 2, //----path_cmd_line_to - path_cmd_curve3 = 3, //----path_cmd_curve3 - path_cmd_curve4 = 4, //----path_cmd_curve4 + path_cmd_stop = 0, //----path_cmd_stop + path_cmd_move_to = 1, //----path_cmd_move_to + path_cmd_line_to = 2, //----path_cmd_line_to + path_cmd_curve3 = 3, //----path_cmd_curve3 + path_cmd_curve4 = 4, //----path_cmd_curve4 path_cmd_curveN = 5, //----path_cmd_curveN path_cmd_catrom = 6, //----path_cmd_catrom path_cmd_ubspline = 7, //----path_cmd_ubspline path_cmd_end_poly = 0x0F, //----path_cmd_end_poly - path_cmd_mask = 0x0F //----path_cmd_mask + path_cmd_mask = 0x0F //----path_cmd_mask }; //------------------------------------------------------------path_flags_e enum path_flags_e { - path_flags_none = 0, //----path_flags_none - path_flags_ccw = 0x10, //----path_flags_ccw - path_flags_cw = 0x20, //----path_flags_cw + path_flags_none = 0, //----path_flags_none + path_flags_ccw = 0x10, //----path_flags_ccw + path_flags_cw = 0x20, //----path_flags_cw path_flags_close = 0x40, //----path_flags_close - path_flags_mask = 0xF0 //----path_flags_mask + path_flags_mask = 0xF0 //----path_flags_mask }; //---------------------------------------------------------------is_vertex @@ -372,7 +372,7 @@ //-----------------------------------------------------------------is_stop inline bool is_stop(unsigned c) - { + { return c == path_cmd_stop; } @@ -416,7 +416,7 @@ inline bool is_close(unsigned c) { return (c & ~(path_flags_cw | path_flags_ccw)) == - (path_cmd_end_poly | path_flags_close); + (path_cmd_end_poly | path_flags_close); } //------------------------------------------------------------is_next_poly @@ -440,19 +440,19 @@ //-------------------------------------------------------------is_oriented inline bool is_oriented(unsigned c) { - return (c & (path_flags_cw | path_flags_ccw)) != 0; + return (c & (path_flags_cw | path_flags_ccw)) != 0; } //---------------------------------------------------------------is_closed inline bool is_closed(unsigned c) { - return (c & path_flags_close) != 0; + return (c & path_flags_close) != 0; } //----------------------------------------------------------get_close_flag inline unsigned get_close_flag(unsigned c) { - return c & path_flags_close; + return c & path_flags_close; } //-------------------------------------------------------clear_orientation @@ -513,7 +513,7 @@ int x1, x2; const T* ptr; const_row_info() {} - const_row_info(int x1_, int x2_, const T* ptr_) : + const_row_info(int x1_, int x2_, const T* ptr_) : x1(x1_), x2(x2_), ptr(ptr_) {} }; Modified: trunk/matplotlib/doc/_templates/indexsidebar.html =================================================================== --- trunk/matplotlib/doc/_templates/indexsidebar.html 2009-08-22 23:20:30 UTC (rev 7523) +++ trunk/matplotlib/doc/_templates/indexsidebar.html 2009-08-22 23:26:25 UTC (rev 7524) @@ -8,18 +8,33 @@ pathto('users/installing') }}">installing</a> </p> -<p>Watch a <a href="http://videolectures.net/mloss08_hunter_mat">video lecture</a> about matplotlib presented at <a href="http://videolectures.net/mloss08_whistler">NIPS 08 Workshop</a> <i>Machine Learning Open Source Software</i></a>. +<p>Build websites like matplotlib's, +with <a href="http://sphinx.pocoo.org/">sphinx</a> and extensions for +mpl plots, math, inheritance diagrams -- try +the <a href="http://matplotlib.sf.net/sampledoc">sampledoc</a> +tutorial. </p> + +<h3>Videos</h3> + +<p>Watch the <a href="http://conference.scipy.org/">SciPy</a> 2009 <a href="http://www.archive.org/details/scipy09_introTutorialDay2_1">intro</a> and <a href="http://www.archive.org/details/scipy09_advancedTutorialDay1_3">advanced</a> matplotlib tutorials +</p> + +<p>Watch a <a href="http://videolectures.net/mloss08_hunter_mat">talk</a> about matplotlib presented at <a href="http://videolectures.net/mloss08_whistler">NIPS 08 Workshop</a> <i>MLOSS</i></a>. +</p> + + +<h3>Toolkits</h3> + <p>There are several matplotlib addon <a href="{{ pathto('users/toolkits') }}">toolkits</a>, including the projection and mapping toolkit <a href="http://matplotlib.sf.net/basemap/doc/html">basemap</a>, 3d plotting with <a href="{{ -pathto('mpl_toolkits/mplot3d/index') }}">mplot3d</a>, wild and wonderful axes and axis helpers in <a href="{{ +pathto('mpl_toolkits/mplot3d/index') }}">mplot3d</a>, axes and axis helpers in <a href="{{ pathto('mpl_toolkits/axes_grid/index') }}">axes_grid</a> and more. </p> - <h3>Need help?</h3> <p>Check the <a href="{{ pathto('users/index') }}">user guide</a>, Modified: trunk/matplotlib/doc/_templates/layout.html =================================================================== --- trunk/matplotlib/doc/_templates/layout.html 2009-08-22 23:20:30 UTC (rev 7523) +++ trunk/matplotlib/doc/_templates/layout.html 2009-08-22 23:26:25 UTC (rev 7524) @@ -2,10 +2,11 @@ {% block rootrellink %} - <li><a href="{{ pathto('index') }}">matplotlib home</a>| </li> + <li><a href="{{ pathto('index') }}">home</a>| </li> <li><a href="{{ pathto('search') }}">search</a>| </li> + <li><a href="examples/index.html">examples</a>| </li> <li><a href="{{ pathto('gallery') }}">gallery</a>| </li> - <li><a href="{{ pathto('contents') }}">documentation </a> »</li> + <li><a href="{{ pathto('contents') }}">docs</a> »</li> {% endblock %} Modified: trunk/matplotlib/doc/faq/installing_faq.rst =================================================================== --- trunk/matplotlib/doc/faq/installing_faq.rst 2009-08-22 23:20:30 UTC (rev 7523) +++ trunk/matplotlib/doc/faq/installing_faq.rst 2009-08-22 23:26:25 UTC (rev 7524) @@ -295,8 +295,8 @@ If you want to install matplotlib from one of the binary installers we build, you have two choices: a dmg installer, which is a typical Installer.app, or an binary OSX egg, which you can install via -setuptools easy_install. - +setuptools easy_install. + The mkpg installer will have a "dmg" extension, and will have a name like :file:`matplotlib-0.99.0-py2.5-macosx10.5.dmg` depending on the python, matplotlib, and OSX versions. Save this file and double @@ -318,10 +318,24 @@ then you will need to set your PYTHONPATH, eg:: - export PYTHONPATH=/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages:$PYTHONPATH + export PYTHONPATH=/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages:$PYTHONPATH See also :ref:`environment-variables`. + +If you are upgrading your matplotlib using the dmg installer over an +Enthought Python Distribution, you may get an error like "You must use +a framework install of python". EPD puts their python in a directory +like :file:``//Library/Frameworks/Python.framework/Versions/4.3.0`` +where 4.3.0 is an EPD version number. The mpl installer needs the +`python` version number, so you need to create a symlink pointing your +python version to the EPS version before installing matplotlib. For +example, for python veersion 2.5 and EPD version 4.3.0:: + + > cd /Library/Frameworks/Python.framework/Versions + > ln -s 4.3.0 2.5 + + .. _easy-install-osx-egg: easy_install from egg @@ -342,7 +356,7 @@ <http://sourceforge.net/projects/matplotlib/files/>`_ directly to your harddrive, and manually install it with - > easy_install --install-dir=~/dev/lib/python2.5/site-packages/ matplotlib-0.99.0.rc1-py2.5-macosx-10.5-i386.egg + > easy_install --install-dir=~/dev/lib/python2.5/site-packages/ matplotlib-0.99.0.rc1-py2.5-macosx-10.5-i386.egg Some users have reported problems with the egg for 0.98 from the @@ -364,6 +378,66 @@ which prevents their installation through easy_install. Renaming is all it takes to install them; still, it's annoying. + +.. _install_from_source_on_osx_epd: + +Building and installing from source on OSX with EPD +--------------------------------------------------- + +If you have the EPD installed (:ref:`which-python-for-osx`), it might turn out +to be rather tricky to install a new version of matplotlib from source on the +Mac OS 10.5 . Here's a procedure that seems to work, at least sometimes: + +0. Remove the ~/.matplotlib folder ("rm -rf ~/.matplotlib"). + +1. Edit the file (make a backup before you start, just in case): +``/Library/Frameworks/Python.framework/Versions/Current/lib/python2.5/config/Makefile``, +removing all occurrences of the string ``-arch ppc``, changing the line +``MACOSX_DEPLOYMENT_TARGET=10.3`` to ``MACOSX_DEPLOYMENT_TARGET=10.5`` and +changing the occurrences of ``MacOSX10.4u.sdk`` into ``MacOSX10.5.sdk`` + +2. In +``/Library/Frameworks/Python.framework/Versions/Current/lib/pythonX.Y/site-packages/easy-install.pth``, +(where X.Y is the version of Python you are building against) +Comment out the line containing the name of the directory in which the +previous version of MPL was installed (Looks something like ``./matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg``). + +3. Save the following as a shell script , for example ``./install-matplotlib-epd-osx.sh`` :: + + NAME=matplotlib + VERSION=0_99 + PREFIX=$HOME + #branch="release" + branch="trunk" + if [ $branch = "trunk" ] + then + echo getting the trunk + svn co https://matplotlib.svn.sourceforge.net/svnroot/$NAME/trunk/$NAME $NAME + cd $NAME + + fi + if [ $branch = "release" ] + then + echo getting the maintenance branch + svn co https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v${VERSION}_maint $NAME$VERSION + cd $NAME$VERSION + fi + export CFLAGS="-Os -arch i386" + export LDFLAGS="-Os -arch i386" + export PKG_CONFIG_PATH="/usr/x11/lib/pkgconfig" + export ARCHFLAGS="-arch i386" + python setup.py build + python setup.py install #--prefix=$PREFIX #Use this if you don't want it installed into your default location + cd .. + +Run this script (for example ``sh ./install-matplotlib-epd-osx.sh``) in the +directory in which you want the source code to be placed, or simply type the +commands in the terminal command line. This script sets some local variable +(CFLAGS, LDFLAGS, PKG_CONFIG_PATH, ARCHFLAGS), removes previous installations, +checks out the source from svn, builds and installs it. The backend seems to be +set to MacOSX. + + Windows questions ================= Property changes on: trunk/matplotlib/doc/pyplots/README ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/pyplots/README:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486 + /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/pyplots/README:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523 Copied: trunk/matplotlib/doc/pyplots/annotate_transform.py (from rev 7523, branches/v0_99_maint/doc/pyplots/annotate_transform.py) =================================================================== --- trunk/matplotlib/doc/pyplots/annotate_transform.py (rev 0) +++ trunk/matplotlib/doc/pyplots/annotate_transform.py 2009-08-22 23:26:25 UTC (rev 7524) @@ -0,0 +1,34 @@ +import numpy as np +import matplotlib.pyplot as plt + +x = np.arange(0, 10, 0.005) +y = np.exp(-x/2.) * np.sin(2*np.pi*x) + +fig = plt.figure() +ax = fig.add_subplot(111) +ax.plot(x, y) +ax.set_xlim(0, 10) +ax.set_ylim(-1, 1) + +xdata, ydata = 5, 0 +xdisplay, ydisplay = ax.transData.transform((xdata, ydata)) + +bbox = dict(boxstyle="round", fc="0.8") +arrowprops = dict( + arrowstyle = "->", + connectionstyle = "angle,angleA=0,angleB=90,rad=10") + +offset = 72 +ax.annotate('data = (%.1f, %.1f)'%(xdata, ydata), + (xdata, ydata), xytext=(-2*offset, offset), textcoords='offset points', + bbox=bbox, arrowprops=arrowprops) + + +disp = ax.annotate('display = (%.1f, %.1f)'%(xdisplay, ydisplay), + (xdisplay, ydisplay), xytext=(0.5*offset, -offset), + xycoords='figure pixels', + textcoords='offset points', + bbox=bbox, arrowprops=arrowprops) + + +plt.show() Copied: trunk/matplotlib/doc/pyplots/compound_path_demo.py (from rev 7523, branches/v0_99_maint/doc/pyplots/compound_path_demo.py) =================================================================== --- trunk/matplotlib/doc/pyplots/compound_path_demo.py (rev 0) +++ trunk/matplotlib/doc/pyplots/compound_path_demo.py 2009-08-22 23:26:25 UTC (rev 7524) @@ -0,0 +1,42 @@ +import numpy as np + +import matplotlib.pyplot as plt +import matplotlib.patches as patches +import matplotlib.path as path + +fig = plt.figure() +ax = fig.add_subplot(111) + +# histogram our data with numpy +data = np.random.randn(1000) +n, bins = np.histogram(data, 100) + +# get the corners of the rectangles for the histogram +left = np.array(bins[:-1]) +right = np.array(bins[1:]) +bottom = np.zeros(len(left)) +top = bottom + n +nrects = len(left) + +nverts = nrects*(1+3+1) +verts = np.zeros((nverts, 2)) +codes = np.ones(nverts, int) * path.Path.LINETO +codes[0::5] = path.Path.MOVETO +codes[4::5] = path.Path.CLOSEPOLY +verts[0::5,0] = left +verts[0::5,1] = bottom +verts[1::5,0] = left +verts[1::5,1] = top +verts[2::5,0] = right +verts[2::5,1] = top +verts[3::5,0] = right +verts[3::5,1] = bottom + +barpath = path.Path(verts, codes) +patch = patches.PathPatch(barpath, facecolor='green', edgecolor='yellow', alpha=0.5) +ax.add_patch(patch) + +ax.set_xlim(left[0], right[-1]) +ax.set_ylim(bottom.min(), top.max()) + +plt.show() Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_gallery.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486 + /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_gallery.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523 Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_rst.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486 + /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_rst.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523 Deleted: trunk/matplotlib/doc/users/annotations.rst =================================================================== --- trunk/matplotlib/doc/users/annotations.rst 2009-08-22 23:20:30 UTC (rev 7523) +++ trunk/matplotlib/doc/users/annotations.rst 2009-08-22 23:26:25 UTC (rev 7524) @@ -1,87 +0,0 @@ -.. _annotations-tutorial: - -Annotating text -=============== - -For a more detailed introduction to annotations, see -:ref:`plotting-guide-annotation`. - -The uses of the basic :func:`~matplotlib.pyplot.text` command above -place text at an arbitrary position on the Axes. A common use case of -text is to annotate some feature of the plot, and the -:func:`~matplotlib.Axes.annotate` method provides helper functionality -to make annotations easy. In an annotation, there are two points to -consider: the location being annotated represented by the argument -``xy`` and the location of the text ``xytext``. Both of these -arguments are ``(x,y)`` tuples. - -.. plot:: pyplots/annotation_basic.py - :include-source: - - -In this example, both the ``xy`` (arrow tip) and ``xytext`` locations -(text location) are in data coordinates. There are a variety of other -coordinate systems one can choose -- you can specify the coordinate -system of ``xy`` and ``xytext`` with one of the following strings for -``xycoords`` and ``textcoords`` (default is 'data') - -==================== ==================================================== -argument coordinate system -==================== ==================================================== - 'figure points' points from the lower left corner of the figure - 'figure pixels' pixels from the lower left corner of the figure - 'figure fraction' 0,0 is lower left of figure and 1,1 is upper, right - 'axes points' points from lower left corner of axes - 'axes pixels' pixels from lower left corner of axes - 'axes fraction' 0,1 is lower left of axes and 1,1 is upper right - 'data' use the axes data coordinate system -==================== ==================================================== - -For example to place the text coordinates in fractional axes -coordinates, one could do:: - - ax.annotate('local max', xy=(3, 1), xycoords='data', - xytext=(0.8, 0.95), textcoords='axes fraction', - arrowprops=dict(facecolor='black', shrink=0.05), - horizontalalignment='right', verticalalignment='top', - ) - -For physical coordinate systems (points or pixels) the origin is the -(bottom, left) of the figure or axes. If the value is negative, -however, the origin is from the (right, top) of the figure or axes, -analogous to negative indexing of sequences. - -Optionally, you can specify arrow properties which draws an arrow -from the text to the annotated point by giving a dictionary of arrow -properties in the optional keyword argument ``arrowprops``. - - -==================== ===================================================== -``arrowprops`` key description -==================== ===================================================== -width the width of the arrow in points -frac the fraction of the arrow length occupied by the head -headwidth the width of the base of the arrow head in points -shrink move the tip and base some percent away from - the annotated point and text - -\*\*kwargs any key for :class:`matplotlib.patches.Polygon`, - e.g. ``facecolor`` -==================== ===================================================== - - -In the example below, the ``xy`` point is in native coordinates -(``xycoords`` defaults to 'data'). For a polar axes, this is in -(theta, radius) space. The text in this example is placed in the -fractional figure coordinate system. :class:`matplotlib.text.Text` -keyword args like ``horizontalalignment``, ``verticalalignment`` and -``fontsize are passed from the `~matplotlib.Axes.annotate` to the -``Text`` instance - -.. plot:: pyplots/annotation_polar.py - :include-source: - -For more on all the wild and wonderful things you can do with -annotations, including fancy arrows, see :ref:`plotting-guide-annotation` -and :ref:`pylab_examples-annotation_demo`. - Copied: trunk/matplotlib/doc/users/annotations_guide.rst (from rev 7523, branches/v0_99_maint/doc/users/annotations_guide.rst) =================================================================== --- trunk/matplotlib/doc/users/annotations_guide.rst (rev 0) +++ trunk/matplotlib/doc/users/annotations_guide.rst 2009-08-22 23:26:25 UTC (rev 7524) @@ -0,0 +1,332 @@ +.. _plotting-guide-annotation: + +**************** +Annotating Axes +**************** + +Do not proceed unless you already have read +:func:`~matplotlib.pyplot.text` and :func:`~matplotlib.pyplot.annotate`! + + +Annotating with Text with Box +============================= + +Let's start with a simple example. + +.. plot:: users/plotting/examples/annotate_text_arrow.py + + +The :func:`~matplotlib.pyplot.text` function in the pyplot module (or +text method of the Axes class) takes bbox keyword argument, and when +given, a box around the text is drawn. :: + + bbox_props = dict(boxstyle="rarrow,pad=0.3", fc="cyan", ec="b", lw=2) + t = ax.text(0, 0, "Direction", ha="center", va="center", rotation=45, + size=15, + bbox=bbox_props) + + +The patch object associated with the text can be accessed by:: + + bb = t.get_bbox_patch() + +The return value is an instance of FancyBboxPatch and the patch +properties like facecolor, edgewidth, etc. can be accessed and +modified as usual. To change the shape of the box, use *set_boxstyle* +method. :: + + bb.set_boxstyle("rarrow", pad=0.6) + +The arguments are the name of the box style with its attributes as +keyword arguments. Currently, followign box styles are implemented. + + ========== ============== ========================== + Class Name Attrs + ========== ============== ========================== + LArrow ``larrow`` pad=0.3 + RArrow ``rarrow`` pad=0.3 + Round ``round`` pad=0.3,rounding_size=None + Round4 ``round4`` pad=0.3,rounding_size=None + Roundtooth ``roundtooth`` pad=0.3,tooth_size=None + Sawtooth ``sawtooth`` pad=0.3,tooth_size=None + Square ``square`` pad=0.3 + ========== ============== ========================== + +.. plot:: mpl_examples/pylab_examples/fancybox_demo2.py + + +Note that the attrubutes arguments can be specified within the style +name with separating comma (this form can be used as "boxstyle" value +of bbox argument when initializing the text instance) :: + + bb.set_boxstyle("rarrow,pad=0.6") + + + + +Annotating with Arrow +===================== + +The :func:`~matplotlib.pyplot.annotate` function in the pyplot module +(or annotate method of the Axes class) is used to draw an arrow +connecting two points on the plot. :: + + ax.annotate("Annotation", + xy=(x1, y1), xycoords='data', + xytext=(x2, y2), textcoords='offset points', + ) + +This annotates a point at ``xy`` in the given coordinate (``xycoords``) +with the text at ``xytext`` given in ``textcoords``. Often, the +annotated point is specified in the *data* coordinate and the annotating +text in *offset points*. +See :func:`~matplotlib.pyplot.annotate` for available coordinate systems. + +An arrow connecting two point (xy & xytext) can be optionally drawn by +specifying the ``arrowprops`` argument. To draw only an arrow, use +empty string as the first argument. :: + + ax.annotate("", + xy=(0.2, 0.2), xycoords='data', + xytext=(0.8, 0.8), textcoords='data', + arrowprops=dict(arrowstyle="->", + connectionstyle="arc3"), + ) + +.. plot:: users/plotting/examples/annotate_simple01.py + +The arrow drawing takes a few steps. + +1. a connecting path between two points are created. This is + controlled by ``connectionstyle`` key value. + +2. If patch object is given (*patchA* & *patchB*), the path is clipped to + avoid the patch. + +3. The path is further shrinked by given amount of pixels (*shirnkA* + & *shrinkB*) + +4. The path is transmuted to arrow patch, which is controlled by the + ``arrowstyle`` key value. + + +.. plot:: users/plotting/examples/annotate_explain.py + + +The creation of the connecting path between two points is controlled by +``connectionstyle`` key and follwing styles are available. + + ========== ============================================= + Name Attrs + ========== ============================================= + ``angle`` angleA=90,angleB=0,rad=0.0 + ``angle3`` angleA=90,angleB=0 + ``arc`` angleA=0,angleB=0,armA=None,armB=None,rad=0.0 + ``arc3`` rad=0.0 + ``bar`` armA=0.0,armB=0.0,fraction=0.3,angle=None + ========== ============================================= + +Note that "3" in ``angle3`` and ``arc3`` is meant to indicate that the +resulting path is a quadratic spline segment (three control +points). As will be discussed below, some arrow style option only can +be used when the connecting path is a quadratic spline. + +The behavior of each connection style is (limitedly) demonstrated in the +example below. (Warning : The behavior of the ``bar`` style is currently not +well defined, it may be changed in the future). + +.. plot:: users/plotting/examples/connectionstyle_demo.py + + +The connecting path (after clipping and shrinking) is then mutated to +an arrow patch, according to the given ``arrowstyle``. + + ========== ============================================= + Name Attrs + ========== ============================================= + ``-`` None + ``->`` head_length=0.4,head_width=0.2 + ``-[`` widthB=1.0,lengthB=0.2,angleB=None + ``-|>`` head_length=0.4,head_width=0.2 + ``<-`` head_length=0.4,head_width=0.2 + ``<->`` head_length=0.4,head_width=0.2 + ``<|-`` head_length=0.4,head_width=0.2 + ``<|-|>`` head_length=0.4,head_width=0.2 + ``fancy`` head_length=0.4,head_width=0.4,tail_width=0.4 + ``simple`` head_length=0.5,head_width=0.5,tail_width=0.2 + ``wedge`` tail_width=0.3,shrink_factor=0.5 + ========== ============================================= + +.. plot:: mpl_examples/pylab_examples/fancyarrow_demo.py + +Some arrowstyles only work with connection style that generates a +quadratic-spline segment. They are ``fancy``, ``simple``, and ``wedge``. +For these arrow styles, you must use "angle3" or "arc3" connection +style. + +If the annotation string is given, the patchA is set to the bbox patch +of the text by default. + +.. plot:: users/plotting/examples/annotate_simple02.py + +As in the text command, a box around the text can be drawn using +the ``bbox`` argument. + +.. plot:: users/plotting/examples/annotate_simple03.py + +By default, the starting point is set to the center of the text +extent. This can be adjusted with ``relpos`` key value. The values +are normalized to the extent of the text. For example, (0,0) means +lower-left corner and (1,1) means top-right. + +.. plot:: users/plotting/examples/annotate_simple04.py + + +Using ConnectorPatch +==================== + +The ConnectorPatch is like an annotation without a text. While the +annotate function is recommended in most of situation, the +ConnectorPatch is useful when you want to connect points in different +axes. :: + + from matplotlib.patches import ConnectionPatch + xy = (0.2, 0.2) + con = ConnectionPatch(xyA=xy, xyB=xy, coordsA="data", coordsB="data", + axesA=ax1, axesB=ax2) + ax2.add_artist(con) + +The above code connects point xy in data coordinate of ``ax1`` to +point xy int data coordiante of ``ax2``. Here is a simple example. + +.. plot:: users/plotting/examples/connect_simple01.py + + +While the ConnectorPatch instance can be added to any axes, but you +may want it to be added to the axes in the latter (?) of the axes +drawing order to prevent overlap (?) by other axes. + + +Placing Artist at the anchored location of the Axes +=================================================== + +There are class of artist that can be placed at the anchored location +of the Axes. A common example is the legend. This type of artists can +be created by using the OffsetBox class. A few predefined classes are +available in ``mpl_toolkits.axes_grid.anchored_artists``. :: + + from mpl_toolkits.axes_grid.anchored_artists import AnchoredText + at = AnchoredText("Figure 1a", + prop=dict(size=8), frameon=True, + loc=2, + ) + at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2") + ax.add_artist(at) + + +.. plot:: users/plotting/examples/anchored_box01.py + + +The *loc* keyword has same meaning as in the legend command. + +A simple application is when the size of the artist (or collection of +artists) is knwon in pixel size during the time of creation. For +example, If you want to draw a circle with fixed size of 20 pixel x 20 +pixel (radius = 10 pixel), you can utilize +``AnchoredDrawingArea``. The instance is created with a size of the +drawing area (in pixel). And user can add arbitrary artist to the +drawing area. Note that the extents of the artists that are added to +the drawing area has nothing to do with the placement of the drawing +area itself. The initial size only matters. :: + + from mpl_toolkits.axes_grid.anchored_artists import AnchoredDrawingArea + + ada = AnchoredDrawingArea(20, 20, 0, 0, + loc=1, pad=0., frameon=False) + p1 = Circle((10, 10), 10) + ada.drawing_area.add_artist(p1) + p2 = Circle((30, 10), 5, fc="r") + ada.drawing_area.add_artist(p2) + +The artists that are added to the drawing area should not have +transform set (they will be overridden) and the dimension of those +artists are interpreted as a pixel coordinate, i.e., the radius of the +circles in above example are 10 pixel and 5 pixel, respectively. + +.. plot:: users/plotting/examples/anchored_box02.py + +Sometimes, you want to your artists scale with data coordinate (or +other coordinate than canvas pixel). You can use +``AnchoredAuxTransformBox`` class. This is similar to +``AnchoredDrawingArea`` except that the extent of the artist is +determined during the drawing time respecting the specified transform. :: + + from mpl_toolkits.axes_grid.anchored_artists import AnchoredAuxTransformBox + + box = AnchoredAuxTransformBox(ax.transData, loc=2) + el = Ellipse((0,0), width=0.1, height=0.4, angle=30) # in data coordinates! + box.drawing_area.add_artist(el) + +The ellipse in the above example will have width and height +corresponds to 0.1 and 0.4 in data coordinate and will be +automatically scaled when the view limits of the axes change. + +.. plot:: users/plotting/examples/anchored_box03.py + +As in the legend, the bbox_to_anchor argument can be set. Using the +HPacker and VPacker, you can have an arrangement(?) of artist as in the +legend (as a matter of fact, this is how the legend is created). + +.. plot:: users/plotting/examples/anchored_box04.py + +Note that unlike the legend, the ``bbox_transform`` is set +to IdentityTransform by default. + +Advanced Topics +*************** + +Zoom effect between Axes +======================== + +mpl_toolkits.axes_grid.inset_locator defines some patch classs useful +for interconnect two axes. Understanding the code requires some +knowledge of how mpl's transform works. But, utilizing it will be +straight forward. + + +.. plot:: mpl_examples/pylab_examples/axes_zoom_effect.py + + +Define Custom BoxStyle +====================== + +You can use a custom box style. The value for the ``boxstyle`` can be a +callable object in following forms.:: + + def __call__(self, x0, y0, width, height, mutation_size, + aspect_ratio=1.): + """ + Given the location and size of the box, return the path of + the box around it. + + - *x0*, *y0*, *width*, *height* : location and size of the box + - *mutation_size* : a reference scale for the mutation. + - *aspect_ratio* : aspect-ration for the mutation. + """ + path = ... + return path + +Here is a complete example. + +.. plot:: users/plotting/examples/custom_boxstyle01.py + +However, it is recommended that you derive from the +matplotlib.patches.BoxStyle._Base as demonstrated below. + +.. plot:: users/plotting/examples/custom_boxstyle02.py + :include-source: + + +Similarly, you can define custom ConnectionStyle and Custome ArrowStyle. +See the source code of ``lib/matplotlib/patches.py`` and check +how each style class is defined. Copied: trunk/matplotlib/doc/users/annotations_intro.rst (from rev 7523, branches/v0_99_maint/doc/users/annotations_intro.rst) =================================================================== --- trunk/matplotlib/doc/users/annotations_intro.rst (rev 0) +++ trunk/matplotlib/doc/users/annotations_intro.rst 2009-08-22 23:26:25 UTC (rev 7524) @@ -0,0 +1,87 @@ +.. _annotations-tutorial: + +Annotating text +=============== + +For a more detailed introduction to annotations, see +:ref:`plotting-guide-annotation`. + +The uses of the basic :func:`~matplotlib.pyplot.text` command above +place text at an arbitrary position on the Axes. A common use case of +text is to annotate some feature of the plot, and the +:func:`~matplotlib.Axes.annotate` method provides helper functionality +to make annotations easy. In an annotation, there are two points to +consider: the location being annotated represented by the argument +``xy`` and the location of the text ``xytext``. Both of these +arguments are ``(x,y)`` tuples. + +.. plot:: pyplots/annotation_basic.py + :include-source: + + +In this example, both the ``xy`` (arrow tip) and ``xytext`` locations +(text location) are in data coordinates. There are a variety of other +coordinate systems one can choose -- you can specify the coordinate +system of ``xy`` and ``xytext`` with one of the following strings for +``xycoords`` and ``textcoords`` (default is 'data') + +==================== ==================================================== +argument coordinate system +==================== ==================================================== + 'figure points' points from the lower left corner of the figure + 'figure pixels' pixels from the lower left corner of the figure + 'figure fraction' 0,0 is lower left of figure and 1,1 is upper, right + 'axes points' points from lower left corner of axes + 'axes pixels' pixels from lower left corner of axes + 'axes fraction' 0,1 is lower left of axes and 1,1 is upper right + 'data' use the axes data coordinate system +==================== ==================================================== + +For example to place the text coordinates in fractional axes +coordinates, one could do:: + + ax.annotate('local max', xy=(3, 1), xycoords='data', + xytext=(0.8, 0.95), textcoords='axes fraction', + arrowprops=dict(facecolor='black', shrink=0.05), + horizontalalignment='right', verticalalignment='top', + ) + +For physical coordinate systems (points or pixels) the origin is the +(bottom, left) of the figure or axes. If the value is negative, +however, the origin is from the (right, top) of the figure or axes, +analogous to negative indexing of sequences. + +Optionally, you can specify arrow properties which draws an arrow +from the text to the annotated point by giving a dictionary of arrow +properties in the optional keyword argument ``arrowprops``. + + +==================== ===================================================== +``arrowprops`` key description +==================== ===================================================== +width the width of the arrow in points +frac the fraction of the arrow length occupied by the head +headwidth the width of the base of the arrow head in points +shrink move the tip and base some percent away from + the annotated point and text + +\*\*kwargs any key for :class:`matplotlib.patches.Polygon`, + e.g. ``facecolor`` +==================== ===================================================== + + +In the example below, the ``xy`` point is in native coordinates +(``xycoords`` defaults to 'data'). For a polar axes, this is in +(theta, radius) space. The text in this example is placed in the +fractional figure coordinate system. :class:`matplotlib.text.Text` +keyword args like ``horizontalalignment``, ``verticalalignment`` and +``fontsize are passed from the `~matplotlib.Axes.annotate` to the +``Text`` instance + +.. plot:: pyplots/annotation_polar.py + :include-source: + +For more on all the wild and wonderful things you can do with +annotations, including fancy arrows, see :ref:`plotting-guide-annotation` +and :ref:`pylab_examples-annotation_demo`. + Modified: trunk/matplotlib/doc/users/artists.rst =================================================================== --- trunk/matplotlib/doc/users/artists.rst 2009-08-22 23:20:30 UTC (rev 7523) +++ trunk/matplotlib/doc/users/artists.rst 2009-08-22 23:26:25 UTC (rev 7524) @@ -37,7 +37,7 @@ :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) create +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`, Modified: trunk/matplotlib/doc/users/index.rst =================================================================== --- trunk/matplotlib/doc/users/index.rst 2009-08-22 23:20:30 UTC (rev 7523) +++ trunk/matplotlib/doc/users/index.rst 2009-08-22 23:26:25 UTC (rev 7524) @@ -20,8 +20,12 @@ shell.rst index_text.rst artists.rst + legend_guide.rst event_handling.rst - plotting.rst + legend.rst + transforms_tutorial.rst + path_tutorial.rst + annotations_guide.rst toolkits.rst screenshots.rst whats_new.rst Modified: trunk/matplotlib/doc/users/index_text.rst =================================================================== --- trunk/matplotlib/doc/users/index_text.rst 2009-08-22 23:20:30 UTC (rev 7523) +++ trunk/matplotlib/doc/users/index_text.rst 2009-08-22 23:26:25 UTC (rev 7524) @@ -9,6 +9,6 @@ text_props.rst mathtext.rst usetex.rst - annotations.rst + annotations_intro.rst Copied: trunk/matplotlib/doc/users/legend_guide.rst (from rev 7523, branches/v0_99_maint/doc/users/legend_guide.rst) =================================================================== --- trunk/matplotlib/doc/users/legend_guide.rst (rev 0) +++ trunk/matplotlib/doc/users/legend_guide.rst 2009-08-22 23:26:25 UTC (rev 7524) @@ -0,0 +1,182 @@ +.. _plotting-guide-legend: + +************ +Legend guide +************ + +Do not proceed unless you already have read :func:`~matplotlib.pyplot.legend` and +:class:`matplotlib.legend.Legend`! + + +What to be displayed +==================== + +The legend command has a following call signature:: + + legend(*args, **kwargs) + +If len(args) is 2, the first argument should be a list of artist to be +labeled, and the second argument should a list of string labels. If +len(args) is 0, it automatically generate the legend from label +properties of the child artists by calling +:meth:`~matplotlib.axes.Axes.get_legend_handles_labels` method. +For example, *ax.legend()* is equivalent to:: + + handles, labels = ax.get_legend_handles_labels() + ax.legend(handles, labels) + +The :meth:`~matplotlib.axes.Axes.get_legend_handles_labels` method +returns a tuple of two lists, i.e., list of artists and list of labels +(python string). However, it does not return all of its child +artists. It returns all artists in *ax.lines* and *ax.patches* and +some artists in *ax.collection* which are instance of +:class:`~matplotlib.collections.LineCollection` or +:class:`~matplotlib.collections.RegularPolyCollection`. The label +attributes (returned by get_label() method) of collected artists are +used as text labels. If label attribute is empty string or starts with +"_", that artist will be ignored. + + + * Note that not all kind of artists are supported by the legend. The + following is the list of artists that are currently supported. + + * :class:`~matplotlib.lines.Line2D` + * :class:`~matplotlib.patches.Patch` + * :class:`~matplotlib.collections.LineCollection` + * :class:`~matplotlib.collections.RegularPolyCollection` + + Unfortunately, there is no easy workaround when you need legend for + an artist not in the above list (You may use one of the supported + artist as a proxy. See below), or customize it beyond what is + supported by :class:`matplotlib.legend.Legend`. + + * Remember that some *pyplot* commands return artist not supported by + legend, e.g., :func:`~matplotlib.pyplot.fill_between` returns + :class:`~matplotlib.collections.PolyCollection` that is not + supported. Or some return multiple artists. For example, + :func:`~matplotlib.pyplot.plot` returns list of + :class:`~matplotlib.lines.Line2D` instances, and + :func:`~matplotlib.pyplot.errorbar` returns a length 3 tuple of + :class:`~matplotlib.lines.Line2D` instances. + + * The legend does not care about the axes that given artists belongs, + i.e., the artists may belong to other axes or even none. + + +Adjusting the Order of Legend items +----------------------------------- + +When you want to customize the list of artists to be displayed in the +legend, or their order of appearance. There are a two options. First, +you can keep lists of artists and labels, and explicitly use these for +the first two argument of the legend call.:: + + p1, = plot([1,2,3]) + p2, = plot([3,2,1]) + p3, = plot([2,3,1]) + legend([p2, p1], ["line 2", "line 1"]) + +Or you may use :meth:`~matplotlib.axes.Axes.get_legend_handles_labels` +to retrieve list of artist and labels and manipulate them before +feeding them to legend call.:: + + ax = subplot(1,1,1) + p1, = ax.plot([1,2,3], label="line 1") + p2, = ax.plot([3,2,1], label="line 2") + p3, = ax.plot([2,3,1], label="line 3") + + handles, labels = ax.get_legend_handles_labels() + + # reverse the order + ax.legend(handles[::-1], labels[::-1]) + + # or sort them by labels + import operator + hl = sorted(zip(handles, labels), + key=operator.itemgetter(1)) + handles2, labels2 = zip(*hl) + + ax.legend(handles2, labels2) + + +Using Proxy Artist +------------------ + +When you want to display legend for an artist not supported by the +matplotlib, you may use other supported artist as a proxy. For +example, you may creates an proxy artist without adding it to the axes +(so the proxy artist will not be drawn in the main axes) and feet it +to the legend function.:: + + p = Rectangle((0, 0), 1, 1, fc="r") + legend([p], ["Red Rectangle"]) + + +Multicolumn Legend +================== + +By specifying the keyword argument *ncol*, you can have a multi-column +legend. Also, mode="expand" horizontally expand the legend to fill the +axes area. See `legend_demo3.py +<http://matplotlib.sourceforge.net/examples/pylab_examples/legend_demo3.html>`_ +for example. + + +Legend location +=============== + +The location of the legend can be specified by the keyword argument +*loc*, either by string or a integer number. + +============= ====== + String Number +============= ====== + upper right 1 + upper left 2 + lower left 3 + lower right 4 + right 5 + center left 6 + center right 7 + lower center 8 + upper center 9 + center 10 +============= ====== + +By default, the legend will anchor to the bbox of the axes +(for legend) or the bbox of the figure (figlegend). You can specify +your own bbox using *bbox_to_anchor* argument. *bbox_to_anchor* can be an +instance of :class:`~matplotlib.transforms.BboxBase`, a tuple of 4 +floats (x, y, width, height of the bbox), or a tuple of 2 floats (x, y +with width=height=0). Unless *bbox_transform* argument is given, the +coordinates (even for the bbox instance) are considered as normalized +axes coordinates. + +For example, if you want your axes legend located at the figure corner +(instead of the axes corner):: + + l = legend(bbox_to_anchor=(0, 0, 1, 1), transform=gcf().transFigure) + +Also, you can place above or outer right-hand side of the axes, + +.. plot:: users/plotting/examples/simple_legend01.py + :include-source: + + +Multiple Legend +=============== + +Sometime, you want to split the legend into multiple ones.:: + + p1, = plot([1,2,3]) + p2, = plot([3,2,1]) + legend([p1], ["Test1"], loc=1) + legend([p2], ["Test2"], loc=4) + +However, the above code only shows the second legend. When the legend +command is called, a new legend instance is created and old ones are +removed from the axes. Thus, you need to manually add the removed +legend. + +.. plot:: users/plotting/examples/simple_legend02.py + :include-source: Copied: trunk/matplotlib/doc/users/path_tutorial.rst (from rev 7523, branches/v0_99_maint/doc/users/path_tutorial.rst) =================================================================== --- trunk/matplotlib/doc/users/path_tutorial.rst (rev 0) +++ trunk/matplotlib/doc/users/path_tutorial.rst 2009-08-22 23:26:25 UTC (rev 7524) @@ -0,0 +1,187 @@ +.. _path_tutorial: + +************* +Path Tutorial +************* + +The object underlying all of the :mod:`matplotlib.patch` objects is +the :class:`~matplotlib.path.Path`, which supports the standard set of +moveto, lineto, curveto commands to draw simple and compound outlines +consisting of line segments and splines. The ``Path`` is instantiated +with a (N,2) array of (x,y) vertices, and a N-length array of path +codes. For example to draw the unit rectangle from (0,0) to (1,1), we +could use this code + +.. plot:: + :include-source: + + import matplotlib.pyplot as plt + from matplotlib.path import Path + import matplotlib.patches as patches + + verts = [ + (0., 0.), # left, bottom + (0., 1.), # left, top + ... [truncated message content] |