

.. _sphx_glr_gallery_api_power_norm.py:


========================
Exploring normalizations
========================

Let's explore various normalization on a multivariate normal distribution.





.. image:: /gallery/api/images/sphx_glr_power_norm_001.png
    :align: center





.. code-block:: python


    from matplotlib import pyplot as plt
    import matplotlib.colors as mcolors
    import numpy as np
    from numpy.random import multivariate_normal

    data = np.vstack([
        multivariate_normal([10, 10], [[3, 2], [2, 3]], size=100000),
        multivariate_normal([30, 20], [[2, 3], [1, 3]], size=1000)
    ])

    gammas = [0.8, 0.5, 0.3]

    fig, axes = plt.subplots(nrows=2, ncols=2)

    axes[0, 0].set_title('Linear normalization')
    axes[0, 0].hist2d(data[:, 0], data[:, 1], bins=100)

    for ax, gamma in zip(axes.flat[1:], gammas):
        ax.set_title('Power law $(\gamma=%1.1f)$' % gamma)
        ax.hist2d(data[:, 0], data[:, 1],
                  bins=100, norm=mcolors.PowerNorm(gamma))

    fig.tight_layout()

    plt.show()

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



.. container:: sphx-glr-footer


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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

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

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