{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Exploring normalizations\n\nVarious normalization on a multivariate normal distribution.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\nfrom numpy.random import multivariate_normal\n\nimport matplotlib.colors as mcolors\n\n# Fixing random state for reproducibility.\nnp.random.seed(19680801)\n\ndata = np.vstack([\n multivariate_normal([10, 10], [[3, 2], [2, 3]], size=100000),\n multivariate_normal([30, 20], [[3, 1], [1, 3]], size=1000)\n])\n\ngammas = [0.8, 0.5, 0.3]\n\nfig, axs = plt.subplots(nrows=2, ncols=2)\n\naxs[0, 0].set_title('Linear normalization')\naxs[0, 0].hist2d(data[:, 0], data[:, 1], bins=100)\n\nfor ax, gamma in zip(axs.flat[1:], gammas):\n ax.set_title(r'Power law $(\\gamma=%1.1f)$' % gamma)\n ax.hist2d(data[:, 0], data[:, 1], bins=100, norm=mcolors.PowerNorm(gamma))\n\nfig.tight_layout()\n\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ".. admonition:: References\n\n The use of the following functions, methods, classes and modules is shown\n in this example:\n\n - `matplotlib.colors`\n - `matplotlib.colors.PowerNorm`\n - `matplotlib.axes.Axes.hist2d`\n - `matplotlib.pyplot.hist2d`\n\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.2" } }, "nbformat": 4, "nbformat_minor": 0 }