今天继续学习python的机器学习,使用了jupyter notebook,学习到绘图模块,结果遇到了bug,情况是

import matplotlib
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["xtick.labelsize"] = 16
plt.rcParams["xtick.color"] = "red"

fig = plt.figure()

这种情况下运行没有出来图形,结果是

<matplotlib.figure.Figure at 0x110b9c450>

如果使用运行

fig.show()

则报错:

UserWarning: matplotlib is currently using a non-GUI backend, so cannot show the figure "matplotlib is currently using a non-GUI backend, "

最后找了半天,尝试了很多解决方案,发现改动一点就可以了:在最前面添加上这行代码即可

%matplotlib notebook

结果如下:

Jupyter Notebook中matplotlib画图bug

 

相关文章:

  • 2021-05-28
  • 2021-04-23
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2022-12-23
  • 2021-10-22
  • 2021-05-07
相关资源
相似解决方案