def setCanvas(self, **kwargs):
"""Set canvas to plot in
:param figure: Matplotlib figure to plot in
:type figure: :py:class:`matplotlib.Figure`
:param axes: Matplotlib axes to plot in
:type axes: :py:class:`matplotlib.Axes`
:raises: TypeError
"""
axes = kwargs.get('axes', None)
figure = kwargs.get('figure', None)
if isinstance(axes, plt.Axes):
self.fig, self.ax = axes.get_figure(), axes
self._show_plt = False
elif isinstance(figure, plt.Figure):
self.fig, self.ax = figure, figure.gca()
self._show_plt = False
elif axes is None and figure is None and self.fig is None:
self.fig, self.ax = plt.subplots(1, 1)
self._show_plt = True
else:
raise TypeError('axes has to be of type matplotlib.Axes. '
'figure has to be of type matplotlib.Figure')
self.image = AxesImage(self.ax)
self.ax.add_artist(self.image)
评论列表
文章目录