Table of Contents
One of the most frequent adjustments required when generating data visualizations is controlling the size of the output figure. Achieving clarity and impact in your graphs often necessitates careful dimensioning, ensuring that labels are readable and data points are not overly crowded. In the Matplotlib library, the standard approach to modify the dimensions of a plot involves utilizing the figure function, specifically through the use of the figsize parameter. This parameter accepts a two-element tuple representing the desired width and height, respectively, with measurements universally defined in inches.
While the primary method is setting the size upon figure initialization, advanced users also have the option to dynamically adjust the dimensions post-creation. This is accomplished using the set_size_inches() method, which is applied directly to the underlying Axes object or the Figure object itself. Both foundational methods provide the necessary flexibility to customize your visualizations, whether you need to adjust a single plot for publication or standardize the dimensions across an entire collection of generated graphics.
Understanding Figure Sizing in Matplotlib
In Matplotlib, a visualization is composed of two primary components: the Figure and the Axes. The Figure acts as the outermost container, serving as the entire canvas where the plot is drawn. The Axes is the region where the data is actually plotted, including the x and y axes, titles, and data markers. When we discuss resizing a plot, we are fundamentally referring to resizing the Figure object, which dictates the overall dimensions of the output image. By default, Matplotlib assigns a standard size to new figures, typically (6.4, 4.8) inches, but this is rarely suitable for all use cases, particularly when preparing charts for reports or academic papers where specific dimensions are often required.
The flexibility in sizing is essential for maintaining visual integrity. A figure that is too small might compress axis labels, making the visualization illegible, while a figure that is excessively large may consume unnecessary screen space or file size without adding value. Therefore, mastering the sizing parameters allows developers and data scientists to create visualizations that are optimized for their intended display medium, whether it be a small inline chart in a Jupyter Notebook or a high-resolution graphic destined for print.
Method 1: Setting Size for a Single Figure Instance
The most granular and common way to control dimensions is by passing the figsize argument directly into the figure() function within the pyplot module. This method ensures that only the currently created figure adheres to the specified dimensions, leaving subsequent figures to use either the default settings or any previously defined global parameters. The value provided to figsize is always interpreted as (width, height), measured in inches. This unit convention is critical to remember, as it directly impacts the physical printed size or the pixel dimensions when combined with the Dots Per Inch (DPI) setting.
To implement this for a specific visualization, you must call plt.figure() before initiating any plotting commands, such as plt.plot() or plt.scatter(). If you call plt.figure() multiple times, each instance will create a new figure object, and the figsize parameter will only apply to the figure object being instantiated at that exact moment. Understanding this sequence is vital for controlling individual plot sizes effectively within a script that generates multiple visualizations.
You can use the following syntax to increase the size of a single plot in Matplotlib:
import matplotlib.pyplot as plt #define figure size in (width, height) for a single plot plt.figure(figsize=(3,3))
Method 2: Configuring Global Plot Sizes Using rcParams
When working in an interactive environment like a Jupyter Notebook or when aiming for a consistent visual style across dozens of plots within a report, setting the figure size individually can become tedious and error-prone. Matplotlib offers a powerful customization system through the runtime configuration parameters, accessible via plt.rcParams. By modifying the figure.figsize entry in rcParams, you can define a new global default size that will apply to every figure created thereafter in the current session, unless explicitly overridden by a local figsize argument.
This method is highly recommended for standardization. For instance, if you know all your charts need to fit a 16:9 aspect ratio and be roughly 10 inches wide, setting this global parameter once at the beginning of your script guarantees consistency. This reduces the boilerplate code required for each individual visualization and ensures that the visual output remains coherent throughout your entire analysis or document.
And you can use the following syntax to increase the size of all Matplotlib plots in a notebook:
import matplotlib.pyplot as plt #define figure size in (width, height) for all plots plt.rcParams['figure.figsize'] = [10, 7]
Note that when setting the dimensions using rcParams, you assign a Python list or tuple containing the width and height values (in inches) to the specific configuration key 'figure.figsize'. This change persists until the kernel is restarted or the parameter is reset manually.
The following examples show how to use this syntax in practice, highlighting the transformation from default settings to custom sizes, both locally and globally.
Example 1: Controlling the Size of a Single Matplotlib Plot
To appreciate the impact of the figsize parameter, we first examine a standard line plot generated without any explicit sizing instructions. By default, pyplot allocates dimensions that typically fit well on standard screens but often lack the necessary scale for detailed analysis or presentation. Suppose we create the following line plot in Matplotlib:
import matplotlib.pyplot as plt #define x and y x = [1, 6, 10] y = [5, 13, 27] #create plot of x and y plt.plot(x, y) plt.show()

As illustrated above, by default, the (width, height) of a Matplotlib plot is typically (6.4, 4.8). This aspect ratio (4:3) is a legacy standard. If our goal is to produce a visualization that is taller than it is wide—for example, to emphasize vertical trends or to fit a specific column layout—we must intervene using the figsize parameter.
To significantly alter the appearance, perhaps making the plot much narrower and taller, we can use the following syntax. Here we define a width of 5 inches and a height of 8 inches, overriding the default settings for this specific figure instance:
import matplotlib.pyplot as plt #define plot size plt.figure(figsize=(5,8)) #define x and y x = [1, 6, 10] y = [5, 13, 27] #create plot of x and y plt.plot(x, y) plt.show()

Notice how the plot retains its internal aspect ratio concerning the data, but the overall container size (the Figure) has been dramatically adjusted, providing more vertical space. This is a crucial distinction: resizing the figure resizes the canvas, but it is the job of the Axes object to scale the actual plotted data to fit within that canvas.
Example 2: Setting Default Size for All Figures
When generating a series of plots, establishing a standard configuration ensures uniformity. This is particularly relevant in data analysis workflows where multiple visualizations are generated sequentially and must share a consistent look and feel. The subsequent code demonstrates how to set the plot size for all Matplotlib plots in a notebook session using rcParams. We define a wide, short plot size (10 inches wide, 4 inches high) to suit a landscape orientation commonly used in presentations.
After setting this configuration parameter, every subsequent call to plt.figure() (or any plotting command that implicitly creates a figure) will adopt these new dimensions. We demonstrate this by creating two distinct plots using separate datasets; both inherit the global setting.
import matplotlib.pyplot as plt #define plot size for all plots plt.rcParams['figure.figsize'] = [10, 4] #define first dataset x = [1, 6, 10] y = [5, 13, 27] #create first plot plt.plot(x, y) plt.show() #define second dataset x2 = [1, 6, 10] y2 = [5, 19, 12] #create second plot plt.plot(x2, y2) plt.show()

Observe the resulting output. Both generated plots exhibit the wide, landscape orientation defined by the rcParams setting [10, 4], successfully demonstrating the global configuration change. This approach is highly efficient for maintaining visual consistency across large projects.
Alternative: Dynamic Sizing with set_size_inches()
While figsize is suitable for initialization, there are scenarios where you might need to adjust the figure dimensions after the figure object has already been created and potentially populated with data. This is where the method fig.set_size_inches(width, height) becomes invaluable. This method is called directly on the Figure object itself, providing programmatic control over resizing based on conditional logic or user input during runtime.
To use this dynamic approach, you must first capture the Figure object, typically done using the Object-Oriented Interface (OOI) of Matplotlib, although it can also be accessed from the pyplot state machine. Here is the general workflow:
- Use
fig = plt.figure()orfig, ax = plt.subplots()to create and capture the Figure object. - Perform your plotting operations (e.g.,
ax.plot(...)). - Use
fig.set_size_inches(new_width, new_height, forward=True)to apply the new size. Theforward=Trueargument is often used to ensure the backend is aware of the change.
This dynamic adjustment is particularly useful in complex scripts where the final required figure size might depend on the volume of data being plotted or constraints imposed by a subsequent layout manager.
Deep Dive into Units: Inches and DPI
A common source of confusion when resizing Matplotlib figures relates to the relationship between the size specified in inches (via figsize) and the final pixel dimensions of the saved image. The figure size in inches determines the physical dimensions if the figure were to be printed at a standard resolution. However, when rendering to a screen or saving to a raster format (like PNG or JPG), the actual pixel count is determined by multiplying the figure size (in inches) by the Dots Per Inch (DPI) setting.
The formula for calculating pixel dimensions is: Pixel Width = Width (in inches) * DPI and Pixel Height = Height (in inches) * DPI. Matplotlib uses a default DPI setting, often 100. Therefore, a figure with figsize=(6, 4) will render at 600×400 pixels by default. If you need a high-resolution image, you should increase the DPI setting, either when saving the figure (e.g., plt.savefig('plot.png', dpi=300)) or globally via rcParams['figure.dpi']. Understanding this relationship is crucial for generating publication-quality images.
Best Practices for Plot Sizing and Aspect Ratio
When deciding on appropriate figure dimensions, several best practices should be considered to ensure optimal visualization quality:
- Aspect Ratio Integrity: Unless specifically required, try to maintain an aspect ratio that logically represents the data. For time series plots, a wider figure (e.g., 10×4) is generally preferred to allow the time axis sufficient space. For correlation plots or scatter plots where X and Y axes represent similar scales, a square figure (e.g., 6×6) is often ideal.
- Text Scalability: Increasing the figure size without proportionally increasing font sizes can lead to tiny, unreadable text. If you dramatically increase the
figsize, consider adjustingrcParamsfor fonts (e.g.,rcParams['font.size']) or dynamically calculating font size based on the new dimensions to maintain readability. - Subplot Management: When dealing with multiple plots within a single figure (using
plt.subplots()), the figure size must accommodate all subplots, including sufficient padding for titles, shared axes, and legends. If subplots appear too cramped, increase thefiguresize and potentially adjust the spacing usingplt.tight_layout()orfig.subplots_adjust().
By judiciously applying figsize locally for specific needs and leveraging rcParams for global consistency, you gain complete mastery over the presentation layer of your data analysis.
Troubleshooting Common Sizing Issues
Despite the simplicity of using figsize, users occasionally encounter issues where the plot size does not seem to update correctly. This is often due to context management or the order of operations.
- Issue 1: Using plt.figure() after plotting: If you call plotting functions (like
plt.plot()) before explicitly callingplt.figure(figsize=...), pyplot will automatically create a figure using the default or global settings, and your subsequentplt.figure()call will create a new, empty figure with the correct size, leaving the original, plotted figure unchanged. Always define the figure size before the first plotting command. - Issue 2: Global vs. Local Overrides: If you set
rcParamsbut then also usefigsize, the localfigsizeparameter will always take precedence for that specific figure. Ensure you are not accidentally passing default or unwanted dimensions locally when you intend to use the global settings. - Issue 3: Subplot Layout Overlap: If the plot dimensions increase significantly, text elements (titles, tick labels) might overlap, especially if the figure border is close to the plotting area. Use
plt.tight_layout()immediately beforeplt.show()to automatically adjust subplot parameters for a tight layout, minimizing clipping and overlap.
By following these guidelines and understanding the distinction between the Figure container and the Axes object, developers can confidently generate professional, perfectly sized visualizations tailored to any output requirement.
Cite this article
stats writer (2025). How to Easily Increase Plot Size in Matplotlib. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-to-increase-plot-size-in-matplotlib/
stats writer. "How to Easily Increase Plot Size in Matplotlib." PSYCHOLOGICAL SCALES, 5 Dec. 2025, https://scales.arabpsychology.com/stats/how-to-increase-plot-size-in-matplotlib/.
stats writer. "How to Easily Increase Plot Size in Matplotlib." PSYCHOLOGICAL SCALES, 2025. https://scales.arabpsychology.com/stats/how-to-increase-plot-size-in-matplotlib/.
stats writer (2025) 'How to Easily Increase Plot Size in Matplotlib', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-to-increase-plot-size-in-matplotlib/.
[1] stats writer, "How to Easily Increase Plot Size in Matplotlib," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, December, 2025.
stats writer. How to Easily Increase Plot Size in Matplotlib. PSYCHOLOGICAL SCALES. 2025;vol(issue):pages.
