推荐的绘图方式是:matplotlib 还是 pylab? [英] Which is the recommended way to plot: matplotlib or pylab?

查看:37
本文介绍了推荐的绘图方式是:matplotlib 还是 pylab?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以下任一方法在 Python绘图:

I can plot in Python using either:

import matplotlib
matplotlib.pyplot.plot(...)

或者:

import pylab
pylab.plot(...)

这两个都使用 matplotlib.

推荐哪种绘图方法是正确的?为什么?

Which is recommend as the correct method to plot? Why?

推荐答案

从官方文档来看,如下图,推荐使用matplotlib.pyplot.这不是意见.

From the official documentation, as shown below, the recommendation is to use matplotlib.pyplot. This is not an opinion.

Matplotlib、pyplot 和 pylab:它们有什么关系?,其中还描述了 pyplot 和 pylab 之间的区别,并指出:尽管许多示例都使用 pylab,但不再推荐使用它.".

The documentation at Matplotlib, pyplot and pylab: how are they related?, which also describes the difference between pyplot and pylab, states: "Although many examples use pylab, it is no longer recommended.".

由于大量导入全局命名空间可能会导致意外行为,因此强烈建议不要使用 pylab.改用 matplotlib.pyplot.>

Since heavily importing into the global namespace may result in unexpected behavior, the use of pylab is strongly discouraged. Use matplotlib.pyplot instead.

这篇关于推荐的绘图方式是:matplotlib 还是 pylab?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆