<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/offset.html">https://matplotlib.org/stable/gallery/mplot3d/offset.html</a></div>
<pclass="last">Click <aclass="reference internal" href="#sphx-glr-download-gallery-mplot3d-offset-py"><spanclass="std std-ref">here</span></a> to download the full example code</p>
<spanid="sphx-glr-gallery-mplot3d-offset-py"></span><h1>Automatic Text Offsetting<aclass="headerlink" href="#automatic-text-offsetting" title="Permalink to this headline">¶</a></h1>
<p>This example demonstrates mplot3d's offset text display.
As one rotates the 3D figure, the offsets should remain oriented the
same way as the axis label, and should also be located "away"
from the center of the plot.</p>
<p>This demo triggers the display of the offset text for the x and
y axis by adding 1e5 to X and Y. Anything less would not
<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="n">X</span><spanclass="p">,</span><spanclass="n">Y</span><spanclass="o">=</span><ahref="https://docs.scipy.org/doc/numpy/reference/generated/numpy.mgrid.html#numpy.mgrid" title="View documentation for numpy.mgrid"><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">mgrid</span></a><spanclass="p">[</span><spanclass="mi">0</span><spanclass="p">:</span><spanclass="mi">6</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="p">:</span><spanclass="mf">0.25</span><spanclass="p">,</span><spanclass="mi">0</span><spanclass="p">:</span><spanclass="mi">4</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="p">:</span><spanclass="mf">0.25</span><spanclass="p">]</span>
<spanclass="n">Z</span><spanclass="o">=</span><ahref="https://docs.scipy.org/doc/numpy/reference/generated/numpy.sqrt.html#numpy.sqrt" title="View documentation for numpy.sqrt"><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">sqrt</span></a><spanclass="p">(</span><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">abs</span><spanclass="p">(</span><ahref="https://docs.scipy.org/doc/numpy/reference/generated/numpy.cos.html#numpy.cos" title="View documentation for numpy.cos"><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">cos</span></a><spanclass="p">(</span><spanclass="n">X</span><spanclass="p">)</span><spanclass="o">+</span><ahref="https://docs.scipy.org/doc/numpy/reference/generated/numpy.cos.html#numpy.cos" title="View documentation for numpy.cos"><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">cos</span></a><spanclass="p">(</span><spanclass="n">Y</span><spanclass="p">)))</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>
<divclass="sphx-glr-footer class sphx-glr-footer-example docutils container" id="sphx-glr-download-gallery-mplot3d-offset-py">