16

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?

2

1 Answer 1

2

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. A Figure object is the outermost container for a matplotlib graphic, which can contain multiple Axes objects.

In short, pyplot is used for plotting, and figure is the container that holds these plots.

Sign up to request clarification or add additional context in comments.

1 Comment

your answer sound's good but for me Gen-AI tool-generated content. Did you check that OP asked also "Can matplotlib.pyplot be used in building a wx app?"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.