Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the difference between matplotlib.pyplot and matplotlib.figure?

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?

like image 391
lamba Avatar asked Mar 27 '11 15:03

lamba


People also ask

What is the difference between plot and figure in matplotlib?

MatPlotLib with PythonPlot − Plot helps to plot just one diagram with (x, y) coordinates. Axes − Axes help to plot one or more diagrams in the same window and sets the location of the figure. Figure − This method provides a top-level container for all the plot elements.

What is a Pyplot figure?

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, etc.

Does matplotlib come with Pyplot?

Is Matplotlib Included in Python? Matplotlib is not a part of the Standard Libraries which is installed by default when Python, there are several toolkits which are available that extend python matplotlib functionality.

Why do we use matplotlib Pyplot?

Matplotlib is a cross-platform, data visualization and graphical plotting library for Python and its numerical extension NumPy. As such, it offers a viable open source alternative to MATLAB. Developers can also use matplotlib's APIs (Application Programming Interfaces) to embed plots in GUI applications.


1 Answers

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.

like image 137
Jouni K. Seppänen Avatar answered Sep 21 '22 10:09

Jouni K. Seppänen