Setting the right figure size helps your charts look clear and professional when you add them to reports or papers.
0
0
Figure size for publication in Matplotlib
Introduction
When you want your plot to fit nicely in a printed report or journal.
When you need consistent sizes for multiple charts in a presentation.
When preparing images for online articles with specific size limits.
When you want to control the resolution and layout of your saved figures.
Syntax
Matplotlib
plt.figure(figsize=(width, height))
width and height are in inches.
Use this before creating your plot to set the size.
Examples
This creates a plot 6 inches wide and 4 inches tall.
Matplotlib
import matplotlib.pyplot as plt plt.figure(figsize=(6, 4)) plt.plot([1, 2, 3], [4, 5, 6]) plt.show()
A square figure, useful for small charts or icons.
Matplotlib
plt.figure(figsize=(3, 3)) plt.bar(['A', 'B'], [10, 20]) plt.show()
A wide and short figure, good for timeline or trend lines.
Matplotlib
plt.figure(figsize=(8, 2)) plt.plot([0, 1, 2], [2, 3, 4]) plt.show()
Sample Program
This code sets the figure size to 5 inches wide and 3 inches tall, then plots a simple line chart with markers. This size is good for fitting into a publication column.
Matplotlib
import matplotlib.pyplot as plt # Set figure size for publication plt.figure(figsize=(5, 3)) # Create a simple line plot x = [0, 1, 2, 3, 4] y = [0, 1, 4, 9, 16] plt.plot(x, y, marker='o') # Add title and labels plt.title('Sample Plot for Publication') plt.xlabel('X axis') plt.ylabel('Y axis') # Show the plot plt.show()
OutputSuccess
Important Notes
Figure size is measured in inches, not pixels.
When saving figures, use plt.savefig('filename.png', dpi=300) for high quality.
Adjusting figure size helps keep text and labels readable in your final output.
Summary
Use plt.figure(figsize=(width, height)) to set plot size in inches.
Choose sizes that fit your publication or presentation layout.
Combine figure size with resolution settings for best results.