{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Histogram 2D size control\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\nx = np.random.randn(1000)\ny = np.random.randn(1000) + 5\n\nplt.figure()\n# normal distribution center at x=0 and y=5\nplt.hist2d(x, y, bins=40)\nplt.show()\n\n# get current figure\ncurrent_figure = plt.gcf()\n\n# set the keepSizeFixed property of the plot to true:\n# current_figure.canvas.manager.itomUI[\"keepSizeFixed\"] = True\n# alternative:\n# plt.get_current_fig_manager().itomUI[\"keepSizeFixed\"]\n\n# change the size\ncurrent_figure.set_dpi(120)\ncurrent_figure.set_size_inches(5, 5, forward=True)" ] } ], "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.8.10" } }, "nbformat": 4, "nbformat_minor": 0 }