A Matplotlib figure comes out blank, empty or with clipped labels. How would you debug it?

Quick Overview

Asks how to debug a Matplotlib or Seaborn figure that renders blank, empty, or with clipped labels. Tests knowledge of plotting backends, the order of show and savefig calls, data problems that hide a plot, and layout options that keep labels inside the image.

A Matplotlib figure comes out blank, empty or with clipped labels. How would you debug it?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

A Matplotlib or Seaborn figure comes out blank, empty, or with clipped labels, and the script raises no error. How would you debug it? ```hint Inspect before you look Ask the figure and its axes what they contain (artists, axis limits, the data behind them) before judging the image, and trace the order in which the figure is created, shown and saved. ``` ### What a Strong Answer Covers - Checks that separate "nothing was plotted" from "something was plotted but is not visible". - Causes in the display path: the backend, the order of `show` and `savefig`, and which figure or axes is current. - Data problems that hide a plot, such as NaNs, empty selections and fixed axis limits. - Layout fixes for clipped labels, both on screen and in saved files. - Reducing the problem to a minimal reproduction. ### Follow-up Questions - Why does `plt.savefig()` called after `plt.show()` often write a blank image? - A figure looks right in a notebook, but the PNG from a headless CI job is cut off. What differs between the two runs? - When would you choose constrained layout over `tight_layout`, and when does neither help? - How would you add an automated check that catches an empty chart in a reporting pipeline?

Overview: Asks how to debug a Matplotlib or Seaborn figure that renders blank, empty, or with clipped labels. Tests knowledge of plotting backends, the order of show and savefig calls, data problems that hide a plot, and layout options that keep labels inside the image.

General logo
General
Nov 24, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

A Matplotlib or Seaborn figure comes out blank, empty, or with clipped labels, and the script raises no error. How would you debug it?

What a Strong Answer Covers Guidance

  • Checks that separate "nothing was plotted" from "something was plotted but is not visible".
  • Causes in the display path: the backend, the order of show and savefig , and which figure or axes is current.
  • Data problems that hide a plot, such as NaNs, empty selections and fixed axis limits.
  • Layout fixes for clipped labels, both on screen and in saved files.
  • Reducing the problem to a minimal reproduction.

Follow-up Questions Guidance

  • Why does plt.savefig() called after plt.show() often write a blank image?
  • A figure looks right in a notebook, but the PNG from a headless CI job is cut off. What differs between the two runs?
  • When would you choose constrained layout over tight_layout , and when does neither help?
  • How would you add an automated check that catches an empty chart in a reporting pipeline?