%matplotlib inline 被注释掉后,pycharm不能生成图

@

问题描述

在 jupyter 编译器中
程序的开头,有这么一行

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt

把这个程序拷贝到pycharm编译器中,出现

在这里插入图片描述
注释掉后
在这里插入图片描述
程序可以运行,结果是

Process finished with exit code 0

但是不会显示图

解决方案

解决如下:

  1. 注释 %matplotlib inline
    在这里插入图片描述

2.在画图的最后面加上

plt.show()


原来

在这里插入图片描述

现在

在这里插入图片描述

其他详情,见:

Matplotlib图表不能在Pycharm中显示的问题 - 听从内心的召唤 - CSDN博客
https://blog.csdn.net/xinluqishi123/article/details/63523531

posted @ 2019-02-19 12:08  JY小脚丫  阅读(3156)  评论(0编辑  收藏  举报