.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "11_demos\python_packages\matplotlib\demo_hist2d_size_control.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_11_demos_python_packages_matplotlib_demo_hist2d_size_control.py: Histogram 2D size control ============================ .. GENERATED FROM PYTHON SOURCE LINES 5-28 .. image-sg:: /11_demos/python_packages/matplotlib/images/sphx_glr_demo_hist2d_size_control_001.png :alt: demo hist2d size control :srcset: /11_demos/python_packages/matplotlib/images/sphx_glr_demo_hist2d_size_control_001.png :class: sphx-glr-single-img .. code-block:: default import matplotlib.pyplot as plt import numpy as np x = np.random.randn(1000) y = np.random.randn(1000) + 5 plt.figure() # normal distribution center at x=0 and y=5 plt.hist2d(x, y, bins=40) plt.show() # get current figure current_figure = plt.gcf() # set the keepSizeFixed property of the plot to true: # current_figure.canvas.manager.itomUI["keepSizeFixed"] = True # alternative: # plt.get_current_fig_manager().itomUI["keepSizeFixed"] # change the size current_figure.set_dpi(120) current_figure.set_size_inches(5, 5, forward=True) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.072 seconds) .. _sphx_glr_download_11_demos_python_packages_matplotlib_demo_hist2d_size_control.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_hist2d_size_control.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_hist2d_size_control.ipynb `