

.. _sphx_glr_gallery_pylab_examples_ellipse_demo.py:


============
Ellipse Demo
============





.. image:: /gallery/pylab_examples/images/sphx_glr_ellipse_demo_001.png
    :align: center





.. code-block:: python

    import matplotlib.pyplot as plt
    import numpy as np
    from matplotlib.patches import Ellipse

    NUM = 250

    ells = [Ellipse(xy=np.random.rand(2)*10,
                    width=np.random.rand(), height=np.random.rand(),
                    angle=np.random.rand()*360)
            for i in range(NUM)]

    fig, ax = plt.subplots(subplot_kw={'aspect': 'equal'})
    for e in ells:
        ax.add_artist(e)
        e.set_clip_box(ax.bbox)
        e.set_alpha(np.random.rand())
        e.set_facecolor(np.random.rand(3))

    ax.set_xlim(0, 10)
    ax.set_ylim(0, 10)

    plt.show()

**Total running time of the script:** ( 0 minutes  0.080 seconds)



.. container:: sphx-glr-footer


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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

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

    `Generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
