本文整理汇总了Python中matplotlib.figure.Figure方法的典型用法代码示例。如果您正苦于以下问题:Python figure.Figure方法的具体用法?Python figure.Figure怎么用?Python figure.Figure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.figure
的用法示例。
在下文中一共展示了figure.Figure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __setup_plot
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def __setup_plot(self):
figure = Figure(facecolor='lightgrey')
self._axes = figure.add_subplot(111)
self._axes.set_title('Spectrum')
self._axes.set_xlabel('Frequency (MHz)')
self._axes.set_ylabel('Level (dB)')
self._axes.autoscale_view(True, True, True)
self._axes.grid(True)
self._spectrum, = self._axes.plot([], [], 'b-', label='Spectrum')
self._canvas = FigureCanvas(self._panelPlot, -1, figure)
self._canvas.mpl_connect('motion_notify_event', self.__on_motion)
Legend.__init__(self, self._axes, self._canvas)
示例2: __setup_plot
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def __setup_plot(self):
figure = Figure(facecolor='lightgrey')
self._axes = figure.add_subplot(111)
self._axes.set_title('Timeline')
self._axes.set_xlabel('Time')
self._axes.set_ylabel('Frequency (MHz)')
self._axes.grid(True)
locator = AutoDateLocator()
formatter = AutoDateFormatter(locator)
self._axes.xaxis.set_major_formatter(formatter)
self._axes.xaxis.set_major_locator(locator)
formatter = ScalarFormatter(useOffset=False)
self._axes.yaxis.set_major_formatter(formatter)
self._axes.yaxis.set_minor_locator(AutoMinorLocator(10))
self._canvas = FigureCanvas(self._panelPlot, -1, figure)
self._canvas.mpl_connect('motion_notify_event', self.__on_motion)
Legend.__init__(self, self._axes, self._canvas)
示例3: __init__
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def __init__(self, parent=None, title='', xlabel='', ylabel='',
xlim=None, ylim=None, xscale='linear', yscale='linear',
width=4, height=3, dpi=100, hold=False):
self.figure = Figure(figsize=(width, height), dpi=dpi)
self.axes = self.figure.add_subplot(111)
self.axes.set_title(title)
self.axes.set_xlabel(xlabel)
self.axes.set_ylabel(ylabel)
if xscale is not None:
self.axes.set_xscale(xscale)
if yscale is not None:
self.axes.set_yscale(yscale)
if xlim is not None:
self.axes.set_xlim(*xlim)
if ylim is not None:
self.axes.set_ylim(*ylim)
self.axes.hold(hold)
Canvas.__init__(self, self.figure)
self.setParent(parent)
Canvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding)
Canvas.updateGeometry(self)
示例4: make_figure_window
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def make_figure_window(self):
self.figure_window = tk.Toplevel(self)
self.figure_window.wm_title('Preview')
screen_dpi = self.figure_window.winfo_fpixels('1i')
screen_width = self.figure_window.winfo_screenwidth() # in pixels
figure_width = screen_width / 2 / screen_dpi
figure_height = 0.75 * figure_width
self.figure = Figure(figsize=(figure_width, figure_height),
dpi=screen_dpi)
ax0 = self.figure.add_subplot(221)
axes = [self.figure.add_subplot(220 + i, sharex=ax0, sharey=ax0)
for i in range(2, 5)]
self.axes = np.array([ax0] + axes)
canvas = FigureCanvasTkAgg(self.figure, master=self.figure_window)
canvas.show()
canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
toolbar = NavigationToolbar2Tk(canvas, self.figure_window)
toolbar.update()
canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
示例5: _format_scalarmappable_value
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def _format_scalarmappable_value(artist, idx): # matplotlib/matplotlib#12473.
data = artist.get_array()[idx]
if np.ndim(data) == 0:
if not artist.colorbar:
fig = Figure()
ax = fig.subplots()
artist.colorbar = fig.colorbar(artist, cax=ax)
# This hack updates the ticks without actually paying the cost of
# drawing (RendererBase.draw_path raises NotImplementedError).
try:
ax.yaxis.draw(RendererBase())
except NotImplementedError:
pass
fmt = artist.colorbar.formatter.format_data_short
return "[" + _strip_math(fmt(data).strip()) + "]"
else:
return artist.format_cursor_data(data) # Includes brackets.
示例6: qSolveFigure
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def qSolveFigure(workspace):
"""GUI layout for quick simplifier
Arguments:
workspace {QtWidgets.QWidget} -- main layout
Returns:
qSolLayout {QtWidgets.QVBoxLayout} -- quick simplifier layout
"""
bg = workspace.palette().window().color()
bgcolor = (bg.redF(), bg.greenF(), bg.blueF())
workspace.qSolveFigure = Figure(edgecolor=bgcolor, facecolor=bgcolor)
workspace.solcanvas = FigureCanvas(workspace.qSolveFigure)
workspace.qSolveFigure.clear()
qSolLayout = QtWidgets.QVBoxLayout()
qSolLayout.addWidget(workspace.solcanvas)
return qSolLayout
示例7: plotFigure2D
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def plotFigure2D(workspace):
"""GUI layout for plot figure
Arguments:
workspace {QtWidgets.QWidget} -- main layout
Returns:
layout {QtWidgets.QVBoxLayout} -- contains matplot figure
"""
workspace.figure2D = Figure()
workspace.canvas2D = FigureCanvas(workspace.figure2D)
# workspace.figure2D.patch.set_facecolor('white')
class NavigationCustomToolbar(NavigationToolbar):
toolitems = [t for t in NavigationToolbar.toolitems if t[0] in ()]
workspace.toolbar2D = NavigationCustomToolbar(workspace.canvas2D, workspace)
layout = QVBoxLayout()
layout.addWidget(workspace.canvas2D)
layout.addWidget(workspace.toolbar2D)
return layout
示例8: plotFigure3D
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def plotFigure3D(workspace):
"""GUI layout for plot figure
Arguments:
workspace {QtWidgets.QWidget} -- main layout
Returns:
layout {QtWidgets.QVBoxLayout} -- contains matplot figure
"""
workspace.figure3D = Figure()
workspace.canvas3D = FigureCanvas(workspace.figure3D)
# workspace.figure3D.patch.set_facecolor('white')
class NavigationCustomToolbar(NavigationToolbar):
toolitems = [t for t in NavigationToolbar.toolitems if t[0] in ()]
workspace.toolbar3D = NavigationCustomToolbar(workspace.canvas3D, workspace)
layout = QVBoxLayout()
layout.addWidget(workspace.canvas3D)
layout.addWidget(workspace.toolbar3D)
return layout
示例9: stepsFigure
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def stepsFigure(workspace):
"""GUI layout for step-by-step solution
Arguments:
workspace {QtWidgets.QWidget} -- main layout
Returns:
stepslayout {QtWidgets.QVBoxLayout} -- step-by-step solution layout
"""
workspace.stepsfigure = Figure()
workspace.stepscanvas = FigureCanvas(workspace.stepsfigure)
workspace.stepsfigure.clear()
workspace.scroll = QScrollArea()
workspace.scroll.setWidget(workspace.stepscanvas)
stepslayout = QVBoxLayout()
stepslayout.addWidget(workspace.scroll)
return stepslayout
示例10: __init__
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def __init__(self, parent, **kwargs):
tk.Frame.__init__(self, parent, **kwargs)
self.parent = parent
self.degree = 5
self.graphFigure = Figure(figsize=(4,2), dpi=100, facecolor="black")
self.subplot = self.graphFigure.add_subplot(1,1,1, facecolor=(0.3, 0.3, 0.3))
self.subplot.tick_params(axis="y", colors="grey", direction="in")
self.subplot.tick_params(axis="x", colors="grey", labelbottom="off", bottom="off")
self.graphFigure.axes[0].get_xaxis().set_ticklabels([])
self.graphFigure.subplots_adjust(left=(30/100), bottom=(15/100),
right=1, top=(1-15/100), wspace=0, hspace=0)
self.canvas = FigureCanvasTkAgg(self.graphFigure, self)
self.canvas.get_tk_widget().configure(bg="black")
self.canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
self.canvas.show()
示例11: makeGraph
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def makeGraph(self):
self.graphFigure = Figure(figsize=(1,0.1), dpi=50, facecolor="black")
self.subplot = self.graphFigure.add_subplot(1,1,1, facecolor=(0.3, 0.3, 0.3))
self.subplot.tick_params(axis="y", colors="grey", labelbottom="off", bottom="off")
self.subplot.tick_params(axis="x", colors="grey", labelbottom="off", bottom="off")
self.graphFigure.axes[0].get_xaxis().set_ticklabels([])
self.graphFigure.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, hspace=0)
self.graphCanvas = FigureCanvasTkAgg(self.graphFigure, self)
self.graphCanvas.get_tk_widget().configure(bg="black")
self.graphCanvas.get_tk_widget().grid(row="2", column="2", columnspan="3", sticky="news")
yValues = self.mainWindow.characterDetector.playbackLogReader.logEntryFrequency
self.highestValue = 0
for value in yValues:
if value > self.highestValue: self.highestValue = value
self.subplot.plot(yValues, "dodgerblue")
self.timeLine, = self.subplot.plot([0, 0], [0, self.highestValue], "white")
#self.graphFigure.axes[0].set_xlim(0, len(yValues))
self.subplot.margins(0.005,0.01)
self.graphCanvas.show()
self.mainWindow.makeDraggable(self.graphCanvas.get_tk_widget())
示例12: __init__
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def __init__(self, parent=None, width=5, height=4, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = fig.add_subplot(111)
# We want the axes cleared every time plot() is called
self.axes.hold(False)
self.compute_initial_figure()
#
FigureCanvas.__init__(self, fig)
self.setParent(parent)
FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
示例13: view
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def view(self, figsize=(5, 5)) -> Tuple[Figure, AxesImage]:
"""View the current state of the board
Parameters
----------
figsize : tuple
Size of the output figure
Returns
-------
(:obj:`matplotlib.figure.Figure`, :obj:`matplotlib.image.AxesImage`)
Graphical view of the board
"""
fig = plt.figure(figsize=figsize)
ax = fig.add_axes([0, 0, 1, 1], xticks=[], yticks=[], frameon=False)
im = ax.imshow(self.state, cmap=plt.cm.binary, interpolation="nearest")
im.set_clim(-0.05, 1)
return fig, im
示例14: view
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def view(self, figsize=(5, 5)) -> Tuple[Figure, AxesImage]:
"""View the lifeform
Returns
-------
matplotlib.axes._subplots.AxesSubplot
Graphical view of the lifeform
"""
fig = plt.figure(figsize=figsize)
ax = fig.add_axes([0, 0, 1, 1], xticks=[], yticks=[], frameon=False)
im = ax.imshow(
self.layout, cmap=plt.cm.binary, interpolation="nearest"
)
im.set_clim(-0.05, 1)
return fig, im
示例15: savefig
# 需要导入模块: from matplotlib import figure [as 别名]
# 或者: from matplotlib.figure import Figure [as 别名]
def savefig(self, figure=None, **kwargs):
"""
Save the Figure instance *figure* to this file as a new page.
If *figure* is a number, the figure instance is looked up by
number, and if *figure* is None, the active figure is saved.
Any other keyword arguments are passed to Figure.savefig.
"""
if isinstance(figure, Figure):
figure.savefig(self, format='pdf', **kwargs)
else:
if figure is None:
figureManager = Gcf.get_active()
else:
figureManager = Gcf.get_fig_manager(figure)
if figureManager is None:
raise ValueError("No such figure: " + repr(figure))
else:
figureManager.canvas.figure.savefig(self, format='pdf', **kwargs)