📅 2014-Oct-27 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ height, matplotlib, size, width ⬩ 📚 Archive
Sometimes you may want to change the width or height or both of the plot figure generated by Matplotlib. For example, you may want the X-axis to be stretched out a bit more and so on.
The size of the plot can be changed by setting the dynamic rc settings of Matplotlib. These are stored in a dictionary named
rcParams. The size of the plot figure is stored with the key
As an example, to get and set the size of a Matplotlib plot:
import matplotlib.pyplot as plt # Get current size = plt.rcParams["figure.figsize"] fig_size # Prints: [8.0, 6.0] print("Current size:", fig_size) # Set figure width to 12 and height to 9 0] = 12 fig_size = 9 fig_size["figure.figsize"] = fig_sizeplt.rcParams[
Tried with: Python 2.7.6 and Ubuntu 14.04