

.. _sphx_glr_gallery_pylab_examples_ellipse_collection.py:


==================
Ellipse Collection
==================





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





.. code-block:: python

    import matplotlib.pyplot as plt
    import numpy as np
    from matplotlib.collections import EllipseCollection

    x = np.arange(10)
    y = np.arange(15)
    X, Y = np.meshgrid(x, y)

    XY = np.hstack((X.ravel()[:, np.newaxis], Y.ravel()[:, np.newaxis]))

    ww = X/10.0
    hh = Y/15.0
    aa = X*9


    fig, ax = plt.subplots()

    ec = EllipseCollection(ww, hh, aa, units='x', offsets=XY,
                           transOffset=ax.transData)
    ec.set_array((X + Y).ravel())
    ax.add_collection(ec)
    ax.autoscale_view()
    ax.set_xlabel('X')
    ax.set_ylabel('y')
    cbar = plt.colorbar(ec)
    cbar.set_label('X+Y')
    plt.show()

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



.. container:: sphx-glr-footer


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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

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

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