热线电话:13121318867

登录
2018-10-30 阅读量: 1095
在ipython shell中如何画图?

matplotlib 在ipython shell中如何画图?

在 IPython shell 中交互式地使用 Matplotlib 画图非常方便, 在 IPython 启动 Matplotlib 模式就可以使用它。 为了启用这个模式, 你需要在启动 ipython 后使用 %matplotlib 魔法命令:

In [1]: %matplotlib
Using matplotlib backend: TkAgg
In [2]: import matplotlib.pyplot as plt

此后的任何 plt 命令都会自动打开一个图形窗口, 增加新的命令,图形就会更新。 有一些变化(例如改变已经画好的线条属性) 不会自动及时更新; 对于这些变化, 可以使用 plt.draw() 强制更新。

在 IPython shell 中启动 Matplotlib 模式之后, 就不需要使用plt.show() 了。

0.0000
1
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子