简体   繁体   中英

Matplotlib showing blank figures in all Jupyter notebooks (no errors)

All Matplotlib figures are showing up blank or empty in my Jupyter notebooks.

Code works (for other people); produces no errors.

Reviewed questions here and here .

Restarted Kernels (in multiple notebooks).

Confirmed that Matplotlib is installed via command prompt in Python:

>>> import matplotlib
>>> matplotlib.__version__
'3.1.1'

For reference, I am also running:

  • Python (3.7.4)
  • Windows 10 Home (Version 10.0.18362, Build 18362)
  • Chrome (Version 79.0.3945.130, Official Build, 64-bit)
  • JupyterLab extension loaded from Anaconda3 installation

This is happening in all my jupyter notebooks, and saving any figs to .png also saves blank .png files.

Created a simple test bar chart with the following code, which produces a blank interactive figure:

%matplotlib notebook

import matplotlib.pyplot as plt
import numpy as np

users = [1000, 2000, 3000, 4000, 5000]
x_axis = np.arange(len(users))
x_axis

fig, ax = plt.subplots()
ax.bar(x_axis, users, color='r', alpha=0.5, align="edge")

The resulting interactive fig does show a "Figure 1" gray interactive bar at the top, and also states the following string at the bottom (since there is no ; at the end of the code):

<BarContainer object of 5 artists>

Not interested in switching to matplotlib inline (wish to keep interactive notebooks).

Any thoughts on how to resolve this blank figures issue please? TIA!

...aaaand turns out someone else (who had recently used my computer) had adjusted a setting in Chrome to block ( ie , not show) images . Yikes! So simple. And so frustrating to have not checked the following setting, which I'm sharing here in case someone else has this same issue:

Chrome-->Settings-->Advanced-->Privacy and security-->Site Settings-->Images-->Show all (slider should be turned ON)

Issue resolved. Figs are now showing (eg, on test code above). Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM