Table of Contents
To adjust the figure size of a Pandas plot, one can use the “figsize” parameter in the plot function. This parameter allows the user to specify the width and height of the plot in inches, allowing for a customized figure size. This can be particularly useful when creating visualizations for different platforms or when displaying multiple plots side by side. By adjusting the figure size, the user can enhance the readability and overall appearance of the plot.
Adjust the Figure Size of a Pandas Plot
You can use the figsize parameter to quickly adjust the figure size of a plot in pandas:
df.plot.scatter(x='x', y='y', figsize=(8,4))
The first value in the figsize parameter specifies the width and the second value specifies the height of the plot.
The following examples show how to use this parameter in practice with the following pandas DataFrame:
import pandas as pd #create DatFrame df = pd.DataFrame({'x': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'y': [5, 7, 7, 9, 10, 14, 13, 15, 19, 16]}) #view head of DataFrame df.head() x y 0 1 5 1 2 7 2 3 7 3 4 9 4 5 10
Example 1: Create Plot with Default Size
The following code shows how to create a scatter plot in pandas using the default plot size:
#create scatter plot with default size df.plot.scatter(x='x', y='y')

Example 2: Create Horizontal Plot
The following code shows how to create a scatter plot in pandas in which the width is twice as long as the height:
#create scatter plot with longer width than height df.plot.scatter(x='x', y='y', figsize=(8,4))

Notice that the plot is much wider than it is tall.
Example 3: Create Vertical Plot
The following code shows how to create a scatter plot in pandas in which the height is twice as long as the width:
#create scatter plot with longer height than width df.plot.scatter(x='x', y='y', figsize=(4,8))

Notice that the plot is much taller than it is wide.
The following tutorials explain how to perform other common tasks in pandas:
Cite this article
stats writer (2024). How can I adjust the figure size of a Pandas plot?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-adjust-the-figure-size-of-a-pandas-plot/
stats writer. "How can I adjust the figure size of a Pandas plot?." PSYCHOLOGICAL SCALES, 27 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-adjust-the-figure-size-of-a-pandas-plot/.
stats writer. "How can I adjust the figure size of a Pandas plot?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-adjust-the-figure-size-of-a-pandas-plot/.
stats writer (2024) 'How can I adjust the figure size of a Pandas plot?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-adjust-the-figure-size-of-a-pandas-plot/.
[1] stats writer, "How can I adjust the figure size of a Pandas plot?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. How can I adjust the figure size of a Pandas plot?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
