matplotlib.pyplot 和 matplotlib.figure 之间有什么区别?
我刚刚开始接触 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.figure 绘图之间有什么区别
和 matplotlib.pyplot
? matplotlib.pyplot 可以用于构建 wx 应用程序吗?
I'm just getting into matplotlib.
I see some examples of matplotlib.pyplot
used, but when integrating matplotlib with wxpython i often see matplotlib.figure
like
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)
What is the difference between plotting using matplotlib.figure
and matplotlib.pyplot
? Can matplotlib.pyplot
be used in building a wx app?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
matplotlib.pyplot
是命令样式函数的集合,使 Matplotlib 像 MATLAB 一样工作。它是 Matplotlib 的基于状态的接口,并提供了一种以程序方式绘制图形的方法,这意味着它会跟踪当前图形和绘图区域等内容,并且绘图函数将定向到当前轴。另一方面,matplotlib.figure 指的是轴、标题、图例和其他元素所在的整个图形或窗口。
Figure
对象是 matplotlib 图形的最外层容器,它可以包含多个Axes
对象。简而言之,
pyplot
用于绘图,figure
是保存这些图的容器。matplotlib.pyplot
is a collection of command style functions that make Matplotlib work like MATLAB. It is state-based interface to Matplotlib and provides a way to plot graphs in a procedural manner, which means it keeps track of things like the current figure and plotting area, and the plotting functions are directed to the current axes.matplotlib.figure
, on the other hand, refers to the whole figure or window where the axes, titles, legends and other elements reside. AFigure
object is the outermost container for a matplotlib graphic, which can contain multipleAxes
objects.In short,
pyplot
is used for plotting, andfigure
is the container that holds these plots.