<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>mplot3d tutorial — Matplotlib v1.1.1 documentation</title> <link rel="stylesheet" href="../../_static/mpl.css" type="text/css" /> <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '1.1.1', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../../_static/jquery.js"></script> <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Matplotlib v1.1.1 documentation" href="../../_static/opensearch.xml"/> <link rel="top" title="Matplotlib v1.1.1 documentation" href="../../index.html" /> </head> <body> <!-- Piwik --> <script type="text/javascript"> if ("matplotlib.sourceforge.net" == document.location.hostname || "matplotlib.sf.net" == document.location.hostname) { var pkBaseURL = (("https:" == document.location.protocol) ? "https://apps.sourceforge.net/piwik/matplotlib/" : "http://apps.sourceforge.net/piwik/matplotlib/"); document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E")); } </script> <script type="text/javascript"> if ("matplotlib.sourceforge.net" == document.location.hostname || "matplotlib.sf.net" == document.location.hostname) { piwik_action_name = ''; piwik_idsite = 1; piwik_url = pkBaseURL + "piwik.php"; piwik_log(piwik_action_name, piwik_idsite, piwik_url); document.write(unescape('%3Cobject%3E%3Cnoscript%3E%3Cp%3E%3Cimg src="http://apps.sourceforge.net/piwik/matplotlib/piwik.php?idsite=1" alt="piwik"/%3E%3C/p%3E%3C/noscript%3E%3C/object%3E')); } </script> <!-- End Piwik Tag --> <link rel="shortcut icon" href="_static/favicon.ico"> <div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px"> <a href="../../index.html"><img src="../../_static/logo2.png" border="0" alt="matplotlib"/></a> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li><a href="../../index.html">home</a>| </li> <li><a href="../../search.html">search</a>| </li> <li><a href="../../examples/index.html">examples</a>| </li> <li><a href="../../gallery.html">gallery</a>| </li> <li><a href="../../contents.html">docs</a> »</li> </ul> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">mplot3d tutorial</a><ul> <li><a class="reference internal" href="#getting-started">Getting started</a></li> <li><a class="reference internal" href="#line-plots">Line plots</a></li> <li><a class="reference internal" href="#scatter-plots">Scatter plots</a></li> <li><a class="reference internal" href="#wireframe-plots">Wireframe plots</a></li> <li><a class="reference internal" href="#surface-plots">Surface plots</a></li> <li><a class="reference internal" href="#contour-plots">Contour plots</a></li> <li><a class="reference internal" href="#filled-contour-plots">Filled contour plots</a></li> <li><a class="reference internal" href="#polygon-plots">Polygon plots</a></li> <li><a class="reference internal" href="#bar-plots">Bar plots</a></li> <li><a class="reference internal" href="#d-plots-in-3d">2D plots in 3D</a></li> <li><a class="reference internal" href="#text">Text</a></li> <li><a class="reference internal" href="#subplotting">Subplotting</a></li> </ul> </li> </ul> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../../_sources/mpl_toolkits/mplot3d/tutorial.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../../search.html" method="get"> <input type="text" name="q" size="18" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="mplot3d-tutorial"> <span id="toolkit-mplot3d-tutorial"></span><h1>mplot3d tutorial<a class="headerlink" href="#mplot3d-tutorial" title="Permalink to this headline">¶</a></h1> <div class="contents topic" id="contents"> <p class="topic-title first">Contents</p> <ul class="simple"> <li><a class="reference internal" href="#mplot3d-tutorial" id="id1">mplot3d tutorial</a><ul> <li><a class="reference internal" href="#getting-started" id="id2">Getting started</a></li> <li><a class="reference internal" href="#line-plots" id="id3">Line plots</a></li> <li><a class="reference internal" href="#scatter-plots" id="id4">Scatter plots</a></li> <li><a class="reference internal" href="#wireframe-plots" id="id5">Wireframe plots</a></li> <li><a class="reference internal" href="#surface-plots" id="id6">Surface plots</a></li> <li><a class="reference internal" href="#contour-plots" id="id7">Contour plots</a></li> <li><a class="reference internal" href="#filled-contour-plots" id="id8">Filled contour plots</a></li> <li><a class="reference internal" href="#polygon-plots" id="id9">Polygon plots</a></li> <li><a class="reference internal" href="#bar-plots" id="id10">Bar plots</a></li> <li><a class="reference internal" href="#d-plots-in-3d" id="id11">2D plots in 3D</a></li> <li><a class="reference internal" href="#text" id="id12">Text</a></li> <li><a class="reference internal" href="#subplotting" id="id13">Subplotting</a></li> </ul> </li> </ul> </div> <div class="section" id="getting-started"> <span id="mplot3d-getting-started"></span><h2>Getting started<a class="headerlink" href="#getting-started" title="Permalink to this headline">¶</a></h2> <p>An Axes3D object is created just like any other axes using the projection=‘3d’ keyword. Create a new <a class="reference internal" href="../../api/figure_api.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure"><tt class="xref py py-class docutils literal"><span class="pre">matplotlib.figure.Figure</span></tt></a> and add a new axes to it of type <tt class="xref py py-class docutils literal"><span class="pre">Axes3D</span></tt>:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="kn">as</span> <span class="nn">plt</span> <span class="kn">from</span> <span class="nn">mpl_toolkits.mplot3d</span> <span class="kn">import</span> <span class="n">Axes3D</span> <span class="n">fig</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">()</span> <span class="n">ax</span> <span class="o">=</span> <span class="n">fig</span><span class="o">.</span><span class="n">add_subplot</span><span class="p">(</span><span class="mi">111</span><span class="p">,</span> <span class="n">projection</span><span class="o">=</span><span class="s">'3d'</span><span class="p">)</span> </pre></div> </div> <p class="versionadded"> <span class="versionmodified">New in version 1.0.0: </span>This approach is the preferred method of creating a 3D axes.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">Prior to version 1.0.0, the method of creating a 3D axes was different. For those using older versions of matplotlib, change <tt class="docutils literal"><span class="pre">ax</span> <span class="pre">=</span> <span class="pre">fig.add_subplot(111,</span> <span class="pre">projection='3d')</span></tt> to <tt class="docutils literal"><span class="pre">ax</span> <span class="pre">=</span> <span class="pre">Axes3D(fig)</span></tt>.</p> </div> </div> <div class="section" id="line-plots"> <span id="plot3d"></span><h2>Line plots<a class="headerlink" href="#line-plots" title="Permalink to this headline">¶</a></h2> <dl class="method"> <dt id="mpl_toolkits.mplot3d.Axes3D.plot"> <tt class="descclassname">Axes3D.</tt><tt class="descname">plot</tt><big>(</big><em>xs</em>, <em>ys</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#mpl_toolkits.mplot3d.Axes3D.plot" title="Permalink to this definition">¶</a></dt> <dd><p>Plot 2D or 3D data.</p> <table border="1" class="docutils"> <colgroup> <col width="17%" /> <col width="83%" /> </colgroup> <thead valign="bottom"> <tr><th class="head">Argument</th> <th class="head">Description</th> </tr> </thead> <tbody valign="top"> <tr><td><em>xs</em>, <em>ys</em></td> <td>X, y coordinates of vertices</td> </tr> <tr><td><em>zs</em></td> <td>z value(s), either one for all points or one for each point.</td> </tr> <tr><td><em>zdir</em></td> <td>Which direction to use as z (‘x’, ‘y’ or ‘z’) when plotting a 2D set.</td> </tr> </tbody> </table> <p>Other arguments are passed on to <a class="reference internal" href="../../api/axes_api.html#matplotlib.axes.Axes.plot" title="matplotlib.axes.Axes.plot"><tt class="xref py py-func docutils literal"><span class="pre">plot()</span></tt></a></p> </dd></dl> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/lines3d_demo.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/lines3d_demo.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/lines3d_demo.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/lines3d_demo.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/lines3d_demo.png" src="../../_images/lines3d_demo.png" /> </div> </div> <div class="section" id="scatter-plots"> <span id="scatter3d"></span><h2>Scatter plots<a class="headerlink" href="#scatter-plots" title="Permalink to this headline">¶</a></h2> <dl class="method"> <dt id="mpl_toolkits.mplot3d.Axes3D.scatter"> <tt class="descclassname">Axes3D.</tt><tt class="descname">scatter</tt><big>(</big><em>xs</em>, <em>ys</em>, <em>zs=0</em>, <em>zdir='z'</em>, <em>s=20</em>, <em>c='b'</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#mpl_toolkits.mplot3d.Axes3D.scatter" title="Permalink to this definition">¶</a></dt> <dd><p>Create a scatter plot.</p> <table border="1" class="docutils"> <colgroup> <col width="15%" /> <col width="85%" /> </colgroup> <thead valign="bottom"> <tr><th class="head">Argument</th> <th class="head">Description</th> </tr> </thead> <tbody valign="top"> <tr><td><em>xs</em>, <em>ys</em></td> <td>Positions of data points.</td> </tr> <tr><td><em>zs</em></td> <td>Either an array of the same length as <em>xs</em> and <em>ys</em> or a single value to place all points in the same plane. Default is 0.</td> </tr> <tr><td><em>zdir</em></td> <td>Which direction to use as z (‘x’, ‘y’ or ‘z’) when plotting a 2D set.</td> </tr> <tr><td><em>s</em></td> <td>size in points^2. It is a scalar or an array of the same length as <em>x</em> and <em>y</em>.</td> </tr> <tr><td><em>c</em></td> <td>a color. <em>c</em> can be a single color format string, or a sequence of color specifications of length <em>N</em>, or a sequence of <em>N</em> numbers to be mapped to colors using the <em>cmap</em> and <em>norm</em> specified via kwargs (see below). Note that <em>c</em> should not be a single numeric RGB or RGBA sequence because that is indistinguishable from an array of values to be colormapped. <em>c</em> can be a 2-D array in which the rows are RGB or RGBA, however.</td> </tr> </tbody> </table> <p>Keyword arguments are passed on to <a class="reference internal" href="../../api/axes_api.html#matplotlib.axes.Axes.scatter" title="matplotlib.axes.Axes.scatter"><tt class="xref py py-func docutils literal"><span class="pre">scatter()</span></tt></a>.</p> <p>Returns a <a class="reference internal" href="api.html#mpl_toolkits.mplot3d.art3d.Patch3DCollection" title="mpl_toolkits.mplot3d.art3d.Patch3DCollection"><tt class="xref py py-class docutils literal"><span class="pre">Patch3DCollection</span></tt></a></p> </dd></dl> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/scatter3d_demo.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/scatter3d_demo.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/scatter3d_demo.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/scatter3d_demo.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/scatter3d_demo.png" src="../../_images/scatter3d_demo.png" /> </div> </div> <div class="section" id="wireframe-plots"> <span id="wireframe"></span><h2>Wireframe plots<a class="headerlink" href="#wireframe-plots" title="Permalink to this headline">¶</a></h2> <dl class="method"> <dt id="mpl_toolkits.mplot3d.Axes3D.plot_wireframe"> <tt class="descclassname">Axes3D.</tt><tt class="descname">plot_wireframe</tt><big>(</big><em>X</em>, <em>Y</em>, <em>Z</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#mpl_toolkits.mplot3d.Axes3D.plot_wireframe" title="Permalink to this definition">¶</a></dt> <dd><p>Plot a 3D wireframe.</p> <table border="1" class="docutils"> <colgroup> <col width="17%" /> <col width="83%" /> </colgroup> <thead valign="bottom"> <tr><th class="head">Argument</th> <th class="head">Description</th> </tr> </thead> <tbody valign="top"> <tr><td><em>X</em>, <em>Y</em>,</td> <td>Data values as 2D arrays</td> </tr> <tr><td><em>Z</em></td> <td> </td> </tr> <tr><td><em>rstride</em></td> <td>Array row stride (step size)</td> </tr> <tr><td><em>cstride</em></td> <td>Array column stride (step size)</td> </tr> </tbody> </table> <p>Keyword arguments are passed on to <a class="reference internal" href="../../api/collections_api.html#matplotlib.collections.LineCollection" title="matplotlib.collections.LineCollection"><tt class="xref py py-class docutils literal"><span class="pre">LineCollection</span></tt></a>.</p> <p>Returns a <a class="reference internal" href="api.html#mpl_toolkits.mplot3d.art3d.Line3DCollection" title="mpl_toolkits.mplot3d.art3d.Line3DCollection"><tt class="xref py py-class docutils literal"><span class="pre">Line3DCollection</span></tt></a></p> </dd></dl> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/wire3d_demo.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/wire3d_demo.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/wire3d_demo.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/wire3d_demo.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/wire3d_demo.png" src="../../_images/wire3d_demo.png" /> </div> </div> <div class="section" id="surface-plots"> <span id="surface"></span><h2>Surface plots<a class="headerlink" href="#surface-plots" title="Permalink to this headline">¶</a></h2> <dl class="method"> <dt id="mpl_toolkits.mplot3d.Axes3D.plot_surface"> <tt class="descclassname">Axes3D.</tt><tt class="descname">plot_surface</tt><big>(</big><em>X</em>, <em>Y</em>, <em>Z</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#mpl_toolkits.mplot3d.Axes3D.plot_surface" title="Permalink to this definition">¶</a></dt> <dd><p>Create a surface plot.</p> <p>By default it will be colored in shades of a solid color, but it also supports color mapping by supplying the <em>cmap</em> argument.</p> <table border="1" class="docutils"> <colgroup> <col width="21%" /> <col width="79%" /> </colgroup> <thead valign="bottom"> <tr><th class="head">Argument</th> <th class="head">Description</th> </tr> </thead> <tbody valign="top"> <tr><td><em>X</em>, <em>Y</em>, <em>Z</em></td> <td>Data values as 2D arrays</td> </tr> <tr><td><em>rstride</em></td> <td>Array row stride (step size)</td> </tr> <tr><td><em>cstride</em></td> <td>Array column stride (step size)</td> </tr> <tr><td><em>color</em></td> <td>Color of the surface patches</td> </tr> <tr><td><em>cmap</em></td> <td>A colormap for the surface patches.</td> </tr> <tr><td><em>facecolors</em></td> <td>Face colors for the individual patches</td> </tr> <tr><td><em>norm</em></td> <td>An instance of Normalize to map values to colors</td> </tr> <tr><td><em>vmin</em></td> <td>Minimum value to map</td> </tr> <tr><td><em>vmax</em></td> <td>Maximum value to map</td> </tr> <tr><td><em>shade</em></td> <td>Whether to shade the facecolors</td> </tr> </tbody> </table> <p>Other arguments are passed on to <a class="reference internal" href="api.html#mpl_toolkits.mplot3d.art3d.Poly3DCollection" title="mpl_toolkits.mplot3d.art3d.Poly3DCollection"><tt class="xref py py-class docutils literal"><span class="pre">Poly3DCollection</span></tt></a></p> </dd></dl> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/surface3d_demo.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/surface3d_demo.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/surface3d_demo.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/surface3d_demo.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/surface3d_demo.png" src="../../_images/surface3d_demo.png" /> </div> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/surface3d_demo2.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/surface3d_demo2.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/surface3d_demo2.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/surface3d_demo2.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/surface3d_demo2.png" src="../../_images/surface3d_demo2.png" /> </div> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/surface3d_demo3.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/surface3d_demo3.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/surface3d_demo3.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/surface3d_demo3.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/surface3d_demo3.png" src="../../_images/surface3d_demo3.png" /> </div> </div> <div class="section" id="contour-plots"> <span id="contour3d"></span><h2>Contour plots<a class="headerlink" href="#contour-plots" title="Permalink to this headline">¶</a></h2> <dl class="method"> <dt id="mpl_toolkits.mplot3d.Axes3D.contour"> <tt class="descclassname">Axes3D.</tt><tt class="descname">contour</tt><big>(</big><em>X</em>, <em>Y</em>, <em>Z</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#mpl_toolkits.mplot3d.Axes3D.contour" title="Permalink to this definition">¶</a></dt> <dd><p>Create a 3D contour plot.</p> <table border="1" class="docutils"> <colgroup> <col width="17%" /> <col width="83%" /> </colgroup> <thead valign="bottom"> <tr><th class="head">Argument</th> <th class="head">Description</th> </tr> </thead> <tbody valign="top"> <tr><td><em>X</em>, <em>Y</em>,</td> <td>Data values as numpy.arrays</td> </tr> <tr><td><em>Z</em></td> <td> </td> </tr> <tr><td><em>extend3d</em></td> <td>Whether to extend contour in 3D (default: False)</td> </tr> <tr><td><em>stride</em></td> <td>Stride (step size) for extending contour</td> </tr> <tr><td><em>zdir</em></td> <td>The direction to use: x, y or z (default)</td> </tr> <tr><td><em>offset</em></td> <td>If specified plot a projection of the contour lines on this position in plane normal to zdir</td> </tr> </tbody> </table> <p>The positional and other keyword arguments are passed on to <a class="reference internal" href="../../api/axes_api.html#matplotlib.axes.Axes.contour" title="matplotlib.axes.Axes.contour"><tt class="xref py py-func docutils literal"><span class="pre">contour()</span></tt></a></p> <p>Returns a <a class="reference internal" href="../../api/axes_api.html#matplotlib.axes.Axes.contour" title="matplotlib.axes.Axes.contour"><tt class="xref py py-class docutils literal"><span class="pre">contour</span></tt></a></p> </dd></dl> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/contour3d_demo.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contour3d_demo.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contour3d_demo.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contour3d_demo.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/contour3d_demo.png" src="../../_images/contour3d_demo.png" /> </div> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/contour3d_demo2.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contour3d_demo2.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contour3d_demo2.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contour3d_demo2.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/contour3d_demo2.png" src="../../_images/contour3d_demo2.png" /> </div> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/contour3d_demo3.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contour3d_demo3.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contour3d_demo3.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contour3d_demo3.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/contour3d_demo3.png" src="../../_images/contour3d_demo3.png" /> </div> </div> <div class="section" id="filled-contour-plots"> <span id="contourf3d"></span><h2>Filled contour plots<a class="headerlink" href="#filled-contour-plots" title="Permalink to this headline">¶</a></h2> <dl class="method"> <dt id="mpl_toolkits.mplot3d.Axes3D.contourf"> <tt class="descclassname">Axes3D.</tt><tt class="descname">contourf</tt><big>(</big><em>X</em>, <em>Y</em>, <em>Z</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#mpl_toolkits.mplot3d.Axes3D.contourf" title="Permalink to this definition">¶</a></dt> <dd><p>Create a 3D contourf plot.</p> <table border="1" class="docutils"> <colgroup> <col width="16%" /> <col width="84%" /> </colgroup> <thead valign="bottom"> <tr><th class="head">Argument</th> <th class="head">Description</th> </tr> </thead> <tbody valign="top"> <tr><td><em>X</em>, <em>Y</em>,</td> <td>Data values as numpy.arrays</td> </tr> <tr><td><em>Z</em></td> <td> </td> </tr> <tr><td><em>zdir</em></td> <td>The direction to use: x, y or z (default)</td> </tr> <tr><td><em>offset</em></td> <td>If specified plot a projection of the filled contour on this position in plane normal to zdir</td> </tr> </tbody> </table> <p>The positional and keyword arguments are passed on to <a class="reference internal" href="../../api/axes_api.html#matplotlib.axes.Axes.contourf" title="matplotlib.axes.Axes.contourf"><tt class="xref py py-func docutils literal"><span class="pre">contourf()</span></tt></a></p> <p>Returns a <a class="reference internal" href="../../api/axes_api.html#matplotlib.axes.Axes.contourf" title="matplotlib.axes.Axes.contourf"><tt class="xref py py-class docutils literal"><span class="pre">contourf</span></tt></a></p> <p class="versionchanged"> <span class="versionmodified">Changed in version 1.1.0: </span>The <em>zdir</em> and <em>offset</em> kwargs were added.</p> </dd></dl> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/contourf3d_demo.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contourf3d_demo.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contourf3d_demo.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contourf3d_demo.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/contourf3d_demo.png" src="../../_images/contourf3d_demo.png" /> </div> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/contourf3d_demo2.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contourf3d_demo2.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contourf3d_demo2.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/contourf3d_demo2.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/contourf3d_demo2.png" src="../../_images/contourf3d_demo2.png" /> </div> <p class="versionadded"> <span class="versionmodified">New in version 1.1.0: </span>The feature demoed in the second contourf3d example was enabled as a result of a bugfix for version 1.1.0.</p> </div> <div class="section" id="polygon-plots"> <span id="polygon3d"></span><h2>Polygon plots<a class="headerlink" href="#polygon-plots" title="Permalink to this headline">¶</a></h2> <dl class="method"> <dt id="mpl_toolkits.mplot3d.Axes3D.add_collection3d"> <tt class="descclassname">Axes3D.</tt><tt class="descname">add_collection3d</tt><big>(</big><em>col</em>, <em>zs=0</em>, <em>zdir='z'</em><big>)</big><a class="headerlink" href="#mpl_toolkits.mplot3d.Axes3D.add_collection3d" title="Permalink to this definition">¶</a></dt> <dd><p>Add a 3D collection object to the plot.</p> <p>2D collection types are converted to a 3D version by modifying the object and adding z coordinate information.</p> <dl class="docutils"> <dt>Supported are:</dt> <dd><ul class="first last simple"> <li>PolyCollection</li> <li>LineColleciton</li> <li>PatchCollection</li> </ul> </dd> </dl> </dd></dl> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/polys3d_demo.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/polys3d_demo.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/polys3d_demo.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/polys3d_demo.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/polys3d_demo.png" src="../../_images/polys3d_demo.png" /> </div> </div> <div class="section" id="bar-plots"> <span id="bar3d"></span><h2>Bar plots<a class="headerlink" href="#bar-plots" title="Permalink to this headline">¶</a></h2> <dl class="method"> <dt id="mpl_toolkits.mplot3d.Axes3D.bar"> <tt class="descclassname">Axes3D.</tt><tt class="descname">bar</tt><big>(</big><em>left</em>, <em>height</em>, <em>zs=0</em>, <em>zdir='z'</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#mpl_toolkits.mplot3d.Axes3D.bar" title="Permalink to this definition">¶</a></dt> <dd><p>Add 2D bar(s).</p> <table border="1" class="docutils"> <colgroup> <col width="17%" /> <col width="83%" /> </colgroup> <thead valign="bottom"> <tr><th class="head">Argument</th> <th class="head">Description</th> </tr> </thead> <tbody valign="top"> <tr><td><em>left</em></td> <td>The x coordinates of the left sides of the bars.</td> </tr> <tr><td><em>height</em></td> <td>The height of the bars.</td> </tr> <tr><td><em>zs</em></td> <td>Z coordinate of bars, if one value is specified they will all be placed at the same z.</td> </tr> <tr><td><em>zdir</em></td> <td>Which direction to use as z (‘x’, ‘y’ or ‘z’) when plotting a 2D set.</td> </tr> </tbody> </table> <p>Keyword arguments are passed onto <a class="reference internal" href="../../api/axes_api.html#matplotlib.axes.Axes.bar" title="matplotlib.axes.Axes.bar"><tt class="xref py py-func docutils literal"><span class="pre">bar()</span></tt></a>.</p> <p>Returns a <a class="reference internal" href="api.html#mpl_toolkits.mplot3d.art3d.Patch3DCollection" title="mpl_toolkits.mplot3d.art3d.Patch3DCollection"><tt class="xref py py-class docutils literal"><span class="pre">Patch3DCollection</span></tt></a></p> </dd></dl> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/bars3d_demo.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/bars3d_demo.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/bars3d_demo.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/bars3d_demo.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/bars3d_demo.png" src="../../_images/bars3d_demo.png" /> </div> </div> <div class="section" id="d-plots-in-3d"> <span id="dcollections3d"></span><h2>2D plots in 3D<a class="headerlink" href="#d-plots-in-3d" title="Permalink to this headline">¶</a></h2> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/2dcollections3d_demo.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/2dcollections3d_demo.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/2dcollections3d_demo.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/2dcollections3d_demo.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/2dcollections3d_demo.png" src="../../_images/2dcollections3d_demo.png" /> </div> </div> <div class="section" id="text"> <span id="text3d"></span><h2>Text<a class="headerlink" href="#text" title="Permalink to this headline">¶</a></h2> <dl class="method"> <dt id="mpl_toolkits.mplot3d.Axes3D.text"> <tt class="descclassname">Axes3D.</tt><tt class="descname">text</tt><big>(</big><em>x</em>, <em>y</em>, <em>z</em>, <em>s</em>, <em>zdir=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#mpl_toolkits.mplot3d.Axes3D.text" title="Permalink to this definition">¶</a></dt> <dd><p>Add text to the plot. kwargs will be passed on to Axes.text, except for the <cite>zdir</cite> keyword, which sets the direction to be used as the z direction.</p> </dd></dl> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/text3d_demo.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/text3d_demo.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/text3d_demo.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/text3d_demo.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/text3d_demo.png" src="../../_images/text3d_demo.png" /> </div> </div> <div class="section" id="subplotting"> <span id="dsubplots"></span><h2>Subplotting<a class="headerlink" href="#subplotting" title="Permalink to this headline">¶</a></h2> <p>Having multiple 3D plots in a single figure is the same as it is for 2D plots. Also, you can have both 2D and 3D plots in the same figure.</p> <p class="versionadded"> <span class="versionmodified">New in version 1.0.0: </span>Subplotting 3D plots was added in v1.0.0. Earlier version can not do this.</p> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/subplot3d_demo.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/subplot3d_demo.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/subplot3d_demo.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/subplot3d_demo.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/subplot3d_demo.png" src="../../_images/subplot3d_demo.png" /> </div> <p>(<a class="reference external" href="../../mpl_examples/mplot3d/mixed_subplots_demo.py">Source code</a>, <a class="reference external" href="../../mpl_examples/mplot3d/mixed_subplots_demo.png">png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/mixed_subplots_demo.hires.png">hires.png</a>, <a class="reference external" href="../../mpl_examples/mplot3d/mixed_subplots_demo.pdf">pdf</a>)</p> <div class="figure"> <img alt="../../_images/mixed_subplots_demo.png" src="../../_images/mixed_subplots_demo.png" /> </div> </div> </div> </div> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li><a href="../../index.html">home</a>| </li> <li><a href="../../search.html">search</a>| </li> <li><a href="../../examples/index.html">examples</a>| </li> <li><a href="../../gallery.html">gallery</a>| </li> <li><a href="../../contents.html">docs</a> »</li> </ul> </div> <div class="footer"> © Copyright 2008, John Hunter, Darren Dale, Michael Droettboom. Last updated on Oct 04, 2012. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7. </div> </body> </html>