本文整理汇总了Python中matplotlib.patches.Rectangle.get_zorder方法的典型用法代码示例。如果您正苦于以下问题:Python Rectangle.get_zorder方法的具体用法?Python Rectangle.get_zorder怎么用?Python Rectangle.get_zorder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.Rectangle
的用法示例。
在下文中一共展示了Rectangle.get_zorder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MatplotlibDataViewer
# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import get_zorder [as 别名]
class MatplotlibDataViewer(DataViewer):
_state_cls = MatplotlibDataViewerState
tools = ['mpl:home', 'mpl:pan', 'mpl:zoom']
subtools = {'save': ['mpl:save']}
def __init__(self, session, parent=None, wcs=None, state=None):
super(MatplotlibDataViewer, self).__init__(session, parent=parent, state=state)
# Use MplWidget to set up a Matplotlib canvas inside the Qt window
self.mpl_widget = MplWidget()
self.setCentralWidget(self.mpl_widget)
# TODO: shouldn't have to do this
self.central_widget = self.mpl_widget
self.figure, self._axes = init_mpl(self.mpl_widget.canvas.fig, wcs=wcs)
for spine in self._axes.spines.values():
spine.set_zorder(ZORDER_MAX)
self.loading_rectangle = Rectangle((0, 0), 1, 1, color='0.9', alpha=0.9,
zorder=ZORDER_MAX - 1, transform=self.axes.transAxes)
self.loading_rectangle.set_visible(False)
self.axes.add_patch(self.loading_rectangle)
self.loading_text = self.axes.text(0.4, 0.5, 'Computing', color='k',
zorder=self.loading_rectangle.get_zorder() + 1,
ha='left', va='center',
transform=self.axes.transAxes)
self.loading_text.set_visible(False)
self.state.add_callback('aspect', self.update_aspect)
self.update_aspect()
self.state.add_callback('x_min', self.limits_to_mpl)
self.state.add_callback('x_max', self.limits_to_mpl)
self.state.add_callback('y_min', self.limits_to_mpl)
self.state.add_callback('y_max', self.limits_to_mpl)
self.limits_to_mpl()
self.state.add_callback('x_log', self.update_x_log, priority=1000)
self.state.add_callback('y_log', self.update_y_log, priority=1000)
self.update_x_log()
self.axes.callbacks.connect('xlim_changed', self.limits_from_mpl)
self.axes.callbacks.connect('ylim_changed', self.limits_from_mpl)
self.axes.set_autoscale_on(False)
self.state.add_callback('x_axislabel', self.update_x_axislabel)
self.state.add_callback('x_axislabel_weight', self.update_x_axislabel)
self.state.add_callback('x_axislabel_size', self.update_x_axislabel)
self.state.add_callback('y_axislabel', self.update_y_axislabel)
self.state.add_callback('y_axislabel_weight', self.update_y_axislabel)
self.state.add_callback('y_axislabel_size', self.update_y_axislabel)
self.state.add_callback('x_ticklabel_size', self.update_x_ticklabel)
self.state.add_callback('y_ticklabel_size', self.update_y_ticklabel)
self.update_x_axislabel()
self.update_y_axislabel()
self.update_x_ticklabel()
self.update_y_ticklabel()
self.central_widget.resize(600, 400)
self.resize(self.central_widget.size())
self._monitor_computation = QTimer()
self._monitor_computation.setInterval(500)
self._monitor_computation.timeout.connect(self._update_computation)
def _update_computation(self, message=None):
# If we get a ComputationStartedMessage and the timer isn't currently
# active, then we start the timer but we then return straight away.
# This is to avoid showing the 'Computing' message straight away in the
# case of reasonably fast operations.
if isinstance(message, ComputationStartedMessage):
if not self._monitor_computation.isActive():
self._monitor_computation.start()
return
for layer_artist in self.layers:
if layer_artist.is_computing:
self.loading_rectangle.set_visible(True)
text = self.loading_text.get_text()
if text.count('.') > 2:
text = 'Computing'
else:
text += '.'
self.loading_text.set_text(text)
self.loading_text.set_visible(True)
self.redraw()
#.........这里部分代码省略.........
示例2: MatplotlibViewerMixin
# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import get_zorder [as 别名]
class MatplotlibViewerMixin(object):
def setup_callbacks(self):
for spine in self.axes.spines.values():
spine.set_zorder(ZORDER_MAX)
self.loading_rectangle = Rectangle((0, 0), 1, 1, color='0.9', alpha=0.9,
zorder=ZORDER_MAX - 1, transform=self.axes.transAxes)
self.loading_rectangle.set_visible(False)
self.axes.add_patch(self.loading_rectangle)
self.loading_text = self.axes.text(0.4, 0.5, 'Computing', color='k',
zorder=self.loading_rectangle.get_zorder() + 1,
ha='left', va='center',
transform=self.axes.transAxes)
self.loading_text.set_visible(False)
self.state.add_callback('aspect', self.update_aspect)
self.update_aspect()
self.state.add_callback('x_min', self.limits_to_mpl)
self.state.add_callback('x_max', self.limits_to_mpl)
self.state.add_callback('y_min', self.limits_to_mpl)
self.state.add_callback('y_max', self.limits_to_mpl)
self.limits_to_mpl()
self.state.add_callback('x_log', self.update_x_log, priority=1000)
self.state.add_callback('y_log', self.update_y_log, priority=1000)
self.update_x_log()
self.axes.callbacks.connect('xlim_changed', self.limits_from_mpl)
self.axes.callbacks.connect('ylim_changed', self.limits_from_mpl)
self.axes.set_autoscale_on(False)
self.state.add_callback('x_axislabel', self.update_x_axislabel)
self.state.add_callback('x_axislabel_weight', self.update_x_axislabel)
self.state.add_callback('x_axislabel_size', self.update_x_axislabel)
self.state.add_callback('y_axislabel', self.update_y_axislabel)
self.state.add_callback('y_axislabel_weight', self.update_y_axislabel)
self.state.add_callback('y_axislabel_size', self.update_y_axislabel)
self.state.add_callback('x_ticklabel_size', self.update_x_ticklabel)
self.state.add_callback('y_ticklabel_size', self.update_y_ticklabel)
self.update_x_axislabel()
self.update_y_axislabel()
self.update_x_ticklabel()
self.update_y_ticklabel()
def _update_computation(self, message=None):
pass
def update_x_axislabel(self, *event):
self.axes.set_xlabel(self.state.x_axislabel,
weight=self.state.x_axislabel_weight,
size=self.state.x_axislabel_size)
self.redraw()
def update_y_axislabel(self, *event):
self.axes.set_ylabel(self.state.y_axislabel,
weight=self.state.y_axislabel_weight,
size=self.state.y_axislabel_size)
self.redraw()
def update_x_ticklabel(self, *event):
self.axes.tick_params(axis='x', labelsize=self.state.x_ticklabel_size)
self.axes.xaxis.get_offset_text().set_fontsize(self.state.x_ticklabel_size)
self.redraw()
def update_y_ticklabel(self, *event):
self.axes.tick_params(axis='y', labelsize=self.state.y_ticklabel_size)
self.axes.yaxis.get_offset_text().set_fontsize(self.state.y_ticklabel_size)
self.redraw()
def redraw(self):
self.figure.canvas.draw()
def update_x_log(self, *args):
self.axes.set_xscale('log' if self.state.x_log else 'linear')
self.redraw()
def update_y_log(self, *args):
self.axes.set_yscale('log' if self.state.y_log else 'linear')
self.redraw()
def update_aspect(self, aspect=None):
self.axes.set_aspect(self.state.aspect, adjustable='datalim')
@avoid_circular
def limits_from_mpl(self, *args):
with delay_callback(self.state, 'x_min', 'x_max', 'y_min', 'y_max'):
if isinstance(self.state.x_min, np.datetime64):
#.........这里部分代码省略.........
示例3: MatplotlibViewerMixin
# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import get_zorder [as 别名]
class MatplotlibViewerMixin(object):
def setup_callbacks(self):
for spine in self.axes.spines.values():
spine.set_zorder(ZORDER_MAX)
self.loading_rectangle = Rectangle((0, 0), 1, 1, color='0.9', alpha=0.9,
zorder=ZORDER_MAX - 1, transform=self.axes.transAxes)
self.loading_rectangle.set_visible(False)
self.axes.add_patch(self.loading_rectangle)
self.loading_text = self.axes.text(0.4, 0.5, 'Computing', color='k',
zorder=self.loading_rectangle.get_zorder() + 1,
ha='left', va='center',
transform=self.axes.transAxes)
self.loading_text.set_visible(False)
self.state.add_callback('x_min', self.limits_to_mpl)
self.state.add_callback('x_max', self.limits_to_mpl)
self.state.add_callback('y_min', self.limits_to_mpl)
self.state.add_callback('y_max', self.limits_to_mpl)
if (self.state.x_min or self.state.x_max or self.state.y_min or self.state.y_max) is None:
self.limits_from_mpl()
else:
self.limits_to_mpl()
self.state.add_callback('x_log', self.update_x_log, priority=1000)
self.state.add_callback('y_log', self.update_y_log, priority=1000)
self.update_x_log()
self.axes.callbacks.connect('xlim_changed', self.limits_from_mpl)
self.axes.callbacks.connect('ylim_changed', self.limits_from_mpl)
self.figure.canvas.mpl_connect('resize_event', self._on_resize)
self._on_resize()
self.axes.set_autoscale_on(False)
self.state.add_callback('x_axislabel', self.update_x_axislabel)
self.state.add_callback('x_axislabel_weight', self.update_x_axislabel)
self.state.add_callback('x_axislabel_size', self.update_x_axislabel)
self.state.add_callback('y_axislabel', self.update_y_axislabel)
self.state.add_callback('y_axislabel_weight', self.update_y_axislabel)
self.state.add_callback('y_axislabel_size', self.update_y_axislabel)
self.state.add_callback('x_ticklabel_size', self.update_x_ticklabel)
self.state.add_callback('y_ticklabel_size', self.update_y_ticklabel)
self.update_x_axislabel()
self.update_y_axislabel()
self.update_x_ticklabel()
self.update_y_ticklabel()
def _update_computation(self, message=None):
pass
def update_x_axislabel(self, *event):
self.axes.set_xlabel(self.state.x_axislabel,
weight=self.state.x_axislabel_weight,
size=self.state.x_axislabel_size)
self.redraw()
def update_y_axislabel(self, *event):
self.axes.set_ylabel(self.state.y_axislabel,
weight=self.state.y_axislabel_weight,
size=self.state.y_axislabel_size)
self.redraw()
def update_x_ticklabel(self, *event):
self.axes.tick_params(axis='x', labelsize=self.state.x_ticklabel_size)
self.axes.xaxis.get_offset_text().set_fontsize(self.state.x_ticklabel_size)
self.redraw()
def update_y_ticklabel(self, *event):
self.axes.tick_params(axis='y', labelsize=self.state.y_ticklabel_size)
self.axes.yaxis.get_offset_text().set_fontsize(self.state.y_ticklabel_size)
self.redraw()
def redraw(self):
self.figure.canvas.draw_idle()
def update_x_log(self, *args):
self.axes.set_xscale('log' if self.state.x_log else 'linear')
self.redraw()
def update_y_log(self, *args):
self.axes.set_yscale('log' if self.state.y_log else 'linear')
self.redraw()
def limits_from_mpl(self, *args, **kwargs):
if getattr(self, '_skip_limits_from_mpl', False):
return
if isinstance(self.state.x_min, np.datetime64):
x_min, x_max = [mpl_to_datetime64(x) for x in self.axes.get_xlim()]
#.........这里部分代码省略.........