<divid="unreleased-message"> You are reading an old version of the documentation (v2.2.4). For the latest version see <ahref="https://matplotlib.org/stable/gallery/mplot3d/pathpatch3d.html">https://matplotlib.org/stable/gallery/mplot3d/pathpatch3d.html</a></div>
<pclass="last">Click <aclass="reference internal" href="#sphx-glr-download-gallery-mplot3d-pathpatch3d-py"><spanclass="std std-ref">here</span></a> to download the full example code</p>
<spanid="sphx-glr-gallery-mplot3d-pathpatch3d-py"></span><h1>Draw flat objects in 3D plot<aclass="headerlink" href="#draw-flat-objects-in-3d-plot" title="Permalink to this headline">¶</a></h1>
<p>Demonstrate using pathpatch_2d_to_3d to 'draw' shapes and text on a 3D plot.</p>
<spanclass="kn">from</span><spanclass="nn">matplotlib.patches</span><spanclass="kn">import</span><ahref="../../api/_as_gen/matplotlib.patches.Circle.html#matplotlib.patches.Circle" title="View documentation for matplotlib.patches.Circle"><spanclass="n">Circle</span></a><spanclass="p">,</span><ahref="../../api/_as_gen/matplotlib.patches.PathPatch.html#matplotlib.patches.PathPatch" title="View documentation for matplotlib.patches.PathPatch"><spanclass="n">PathPatch</span></a>
<spanclass="c1"># register Axes3D class with matplotlib by importing Axes3D</span>
<spanclass="kn">from</span><spanclass="nn">matplotlib.transforms</span><spanclass="kn">import</span><ahref="../../api/transformations.html#matplotlib.transforms.Affine2D" title="View documentation for matplotlib.transforms.Affine2D"><spanclass="n">Affine2D</span></a>
<spanclass="n">trans</span><spanclass="o">=</span><ahref="../../api/transformations.html#matplotlib.transforms.Affine2D" title="View documentation for matplotlib.transforms.Affine2D"><spanclass="n">Affine2D</span></a><spanclass="p">()</span><spanclass="o">.</span><spanclass="n">rotate</span><spanclass="p">(</span><spanclass="n">angle</span><spanclass="p">)</span><spanclass="o">.</span><spanclass="n">translate</span><spanclass="p">(</span><spanclass="n">xy1</span><spanclass="p">[</span><spanclass="mi">0</span><spanclass="p">],</span><spanclass="n">xy1</span><spanclass="p">[</span><spanclass="mi">1</span><spanclass="p">])</span>
<spanclass="n">p1</span><spanclass="o">=</span><ahref="../../api/_as_gen/matplotlib.patches.PathPatch.html#matplotlib.patches.PathPatch" title="View documentation for matplotlib.patches.PathPatch"><spanclass="n">PathPatch</span></a><spanclass="p">(</span><spanclass="n">trans</span><spanclass="o">.</span><spanclass="n">transform_path</span><spanclass="p">(</span><spanclass="n">text_path</span><spanclass="p">),</span><spanclass="o">**</span><spanclass="n">kwargs</span><spanclass="p">)</span>
<spanclass="n">fig</span><spanclass="o">=</span><ahref="../../api/_as_gen/matplotlib.pyplot.figure.html#matplotlib.pyplot.figure" title="View documentation for matplotlib.pyplot.figure"><spanclass="n">plt</span><spanclass="o">.</span><spanclass="n">figure</span></a><spanclass="p">()</span>
<spanclass="c1"># Draw a circle on the x=0 'wall'</span>
<spanclass="n">p</span><spanclass="o">=</span><ahref="../../api/_as_gen/matplotlib.patches.Circle.html#matplotlib.patches.Circle" title="View documentation for matplotlib.patches.Circle"><spanclass="n">Circle</span></a><spanclass="p">((</span><spanclass="mi">5</span><spanclass="p">,</span><spanclass="mi">5</span><spanclass="p">),</span><spanclass="mi">3</span><spanclass="p">)</span>
<spanclass="n">angle</span><spanclass="o">=</span><ahref="https://docs.scipy.org/doc/numpy/reference/constants.html#numpy.pi" title="View documentation for numpy.pi"><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">pi</span></a><spanclass="o">/</span><spanclass="mi">2</span><spanclass="p">,</span><spanclass="n">ec</span><spanclass="o">=</span><spanclass="s2">"none"</span><spanclass="p">,</span><spanclass="n">fc</span><spanclass="o">=</span><spanclass="s2">"k"</span><spanclass="p">)</span>
<spanclass="n">angle</span><spanclass="o">=</span><ahref="https://docs.scipy.org/doc/numpy/reference/constants.html#numpy.pi" title="View documentation for numpy.pi"><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">pi</span></a><spanclass="o">/</span><spanclass="mi">2</span><spanclass="p">,</span><spanclass="n">ec</span><spanclass="o">=</span><spanclass="s2">"none"</span><spanclass="p">,</span><spanclass="n">fc</span><spanclass="o">=</span><spanclass="s2">"k"</span><spanclass="p">)</span>
<spanclass="c1"># Write a Latex formula on the z=0 'floor'</span>
<ahref="../../api/_as_gen/matplotlib.pyplot.show.html#matplotlib.pyplot.show" title="View documentation for matplotlib.pyplot.show"><spanclass="n">plt</span><spanclass="o">.</span><spanclass="n">show</span></a><spanclass="p">()</span>
</pre></div>
</div>
<p><strong>Total running time of the script:</strong> ( 0 minutes 1.065 seconds)</p>
<divclass="sphx-glr-footer class sphx-glr-footer-example docutils container" id="sphx-glr-download-gallery-mplot3d-pathpatch3d-py">