
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/mplot3d/axlim_clip.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. meta::
        :keywords: codex

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_gallery_mplot3d_axlim_clip.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_mplot3d_axlim_clip.py:


=====================================
Clip the data to the axes view limits
=====================================

Demonstrate clipping of line and marker data to the axes view limits. The
``axlim_clip`` keyword argument can be used in any of the 3D plotting
functions.

.. GENERATED FROM PYTHON SOURCE LINES 10-37

.. code-block:: Python


    import matplotlib.pyplot as plt
    import numpy as np

    fig, ax = plt.subplots(subplot_kw={"projection": "3d"})

    # Make the data
    x = np.arange(-5, 5, 0.5)
    y = np.arange(-5, 5, 0.5)
    X, Y = np.meshgrid(x, y)
    R = np.sqrt(X**2 + Y**2)
    Z = np.sin(R)

    # Default behavior is axlim_clip=False
    ax.plot_wireframe(X, Y, Z, color='C0')

    # When axlim_clip=True, note that when a line segment has one vertex outside
    # the view limits, the entire line is hidden. The same is true for 3D patches
    # if one of their vertices is outside the limits (not shown).
    ax.plot_wireframe(X, Y, Z, color='C1', axlim_clip=True)

    # In this example, data where x < 0 or z > 0.5 is clipped
    ax.set(xlim=(0, 10), ylim=(-5, 5), zlim=(-1, 0.5))
    ax.legend(['axlim_clip=False (default)', 'axlim_clip=True'])

    plt.show()


.. GENERATED FROM PYTHON SOURCE LINES 38-41

.. tags::
   plot-type: 3D,
   level: beginner


.. _sphx_glr_download_gallery_mplot3d_axlim_clip.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: axlim_clip.ipynb <axlim_clip.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: axlim_clip.py <axlim_clip.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: axlim_clip.zip <axlim_clip.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
