matplotlib.pyplot和matplotlib.figure有什么区别? [英] what's the difference between matplotlib.pyplot and matplotlib.figure?

查看:89
本文介绍了matplotlib.pyplot和matplotlib.figure有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始接触 matplotlib.

I'm just getting into matplotlib.

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

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)

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

What is the difference between plotting using matplotlib.figure and matplotlib.pyplot? Can matplotlib.pyplot be used in building a wx app?

推荐答案

Pyplot是类似于Matlab的状态机API,即matplotlib.figure.Figure是面向对象API的一部分.见例如本教程,以开始使用面向对象的API.如果要创建wx应用,>您很可能需要学习OO API .

Pyplot is the Matlab-like state-machine API, matplotlib.figure.Figure is part of the object-oriented API. See e.g. this tutorial to get started with the object-oriented API. If you want to create a wx app, you will most likely need to learn the OO API.

这篇关于matplotlib.pyplot和matplotlib.figure有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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