【问题标题】:what's the difference between matplotlib.pyplot and matplotlib.figure?matplotlib.pyplot 和 matplotlib.figure 有什么区别?
【发布时间】:2011-03-27 15:29:37
【问题描述】:

我刚刚进入 matplotlib。

我看到一些使用 matplotlib.pyplot 的例子,但是在将 matplotlib 与 wxpython 集成时,我经常看到 matplotlib.figure 之类的

from matplotlib.figure import Figure

...

vboxFigure = wx.BoxSizer(wx.VERTICAL)
self.figure = Figure()
self.axes = self.figure.add_subplot(111)

t = [1,2,3,4,5]
s = [0,0,0,0,0]

self.axes.plot(t,s, 'b-')
self.canvas = FigureCanvas(panel, -1, self.figure)

vboxFigure.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND)
hbox.Add(vboxFigure, 1, flag=wx.EXPAND)

使用matplotlib.figurematplotlib.pyplot 进行绘图有什么区别? matplotlib.pyplot可以用于构建wx应用吗?

【问题讨论】:

  • 几乎我能找到的所有示例都使用figure,但我有一个使用pyplot 的基本工作示例,只是想更改轴格式。您没有必须为此使用figure;参见例如matplotlib.org/users/pyplot_tutorial.html

标签: python wxpython matplotlib


【解决方案1】:

Pyplot 是类似于 Matlab 的状态机 API,matplotlib.figure.Figure 是面向对象 API 的一部分。参见例如this tutorial 开始使用面向对象的 API。如果你想创建一个 wx 应用,you will most likely need to learn the OO API.

【讨论】:

  • 由于教程的原始链接已损坏,我将其修复为指向 web.archive.org 上的最后一个快照
猜你喜欢
  • 2013-01-11
  • 2016-08-08
  • 2010-10-02
  • 2011-12-12
  • 2010-09-16
  • 2012-03-14
  • 2012-02-06
  • 2011-02-25
  • 2011-11-22
相关资源
最近更新 更多