Bird
0
0

You want to save a figure with a transparent background but the saved PNG still shows a white background. Which additional step can fix this?

hard📝 Application Q9 of 15
Matplotlib - Export and Publication Quality
You want to save a figure with a transparent background but the saved PNG still shows a white background. Which additional step can fix this?
ASet transparent=False in plt.savefig().
BSet the axes facecolor to 'none' before saving.
CChange the plot line color to white.
DSave the figure as a JPEG instead of PNG.
Step-by-Step Solution
Solution:
  1. Step 1: Identify why white background appears despite transparent=True

    The axes background color defaults to white, which shows up in the saved image.
  2. Step 2: Fix by setting axes facecolor to 'none'

    Setting ax.set_facecolor('none') removes the white background, allowing transparency.
  3. Final Answer:

    Set the axes facecolor to 'none' before saving. -> Option B
  4. Quick Check:

    Axes facecolor='none' enables transparent background [OK]
Quick Trick: Set axes facecolor='none' for true transparency [OK]
Common Mistakes:
  • Setting transparent=False disables transparency
  • Changing line color doesn't affect background
  • Saving as JPEG removes transparency support

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes