figure of imshow is too small
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
When an imshow plot looks too small, the image data is usually fine and the figure container is the real problem. In Matplotlib, the most direct fix is to create a larger figure with an explicit figsize, and sometimes to raise the DPI if the rendered result still looks cramped.
Why imshow Looks Small
imshow draws an image inside the current axes. If you do not control the figure size, Matplotlib uses its defaults, which can be too compact for large arrays, notebook output cells, or high-DPI displays.
This means there are two different concepts:
- image resolution, which comes from the array shape
- displayed figure size, which comes from figure settings
Changing one does not automatically change the other.
The Simplest Fix: Set figsize
Start by creating the figure yourself before calling imshow:
The figsize values are measured in inches. A larger width and height give the image more room on screen and in saved output.
If you prefer the object-oriented style:
That is often easier to manage in real projects.
DPI Affects Sharpness More Than Layout
Sometimes the figure is physically large enough, but it still looks blurry or too dense when saved. That is where DPI matters.
Higher DPI increases pixel density in the rendered figure. It does not replace figsize, but it can make details more readable in exported images.
When saving:
This is especially useful for reports or slides.
Notebook and Inline Display Issues
In Jupyter notebooks, plots may still appear small because the notebook frontend constrains their display area. You can raise the default figure size for the session:
After that, future plots inherit the larger defaults unless overridden.
If you only change the array size but not the figure size, the notebook may still render the plot into a small output box. That is why editing figsize is usually the first thing to try.
Aspect Ratio and Axes Choices
The figure may also look awkward if the aspect ratio does not match the image shape. imshow preserves aspect by default, which is often correct, but it can leave unused space or make one dimension feel cramped.
Use aspect="auto" only when stretching is acceptable. For scientific or image-processing work, preserving the true pixel aspect is often more important than filling the available area.
Also consider removing unnecessary axes decorations if the image itself is what matters:
That gives more visual space to the data.
Common Pitfalls
One common mistake is calling plt.imshow first and then wondering why the defaults are too small. Set up the figure before plotting.
Another mistake is increasing DPI when the real issue is layout size. DPI affects detail and export sharpness, but figsize controls how much room the axes get.
It is also easy to overlook notebook-specific display limits. If a figure looks fine when saved but small inline, the frontend is likely constraining it.
Summary
- '
imshowuses the current figure and axes size, so small output often means a small figure.' - Fix it first with
plt.figure(figsize=(...))orplt.subplots(figsize=(...)). - Use DPI to improve sharpness, especially when saving images.
- Set
rcParamsin notebooks if many plots need larger defaults. - Adjust aspect and axes visibility only after the figure size is right.

