本文整理汇总了Python中matplotlib.backends.backend_qt4.NavigationToolbar2QT.show方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QT.show方法的具体用法?Python NavigationToolbar2QT.show怎么用?Python NavigationToolbar2QT.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4.NavigationToolbar2QT
的用法示例。
在下文中一共展示了NavigationToolbar2QT.show方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PylabPlotter
# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import show [as 别名]
class PylabPlotter(GriddedPlugin):
""" a class to visualize data from external pylab graphics files """
_icon = pixmaps.bars3d
viewer_name = "Pylab Plotter"
def is_viewable(data):
return len(data) > 0
is_viewable = staticmethod(is_viewable)
def __init__(self, gw, dataitem, cellspec={}, **opts):
GriddedPlugin.__init__(self, gw, dataitem, cellspec=cellspec)
""" a plugin for showing pylab plots """
self._rec = None
self._wtop = None
self.dataitem = dataitem
self.png_number = 0
self.data_list = []
self.data_list_labels = []
self.data_list_length = 0
self.max_list_length = 50
self.layout_created = False
self.counter = -1
self.reset_plot_stuff()
# back to 'real' work
if dataitem and dataitem.data is not None:
self.set_data(dataitem)
def reset_plot_stuff(self):
""" resets widgets to None. Needed if we have been putting
out a message about Cache not containing results, etc
"""
self._pylab_plotter = None
self._toolbar = None
self.results_selector = None
self.status_label = None
self.layout_parent = None
self.layout = None
def wtop(self):
""" function needed by Oleg for reasons known only to him! """
return self._wtop
def create_layout_stuff(self):
""" create grid layouts into which plotter widgets are inserted """
if self.layout_parent is None or not self.layout_created:
self.layout_parent = Qt.QWidget(self.wparent())
self.layout = Qt.QGridLayout(self.layout_parent)
self.set_widgets(self.layout_parent, self.dataitem.caption, icon=self.icon())
self.layout_created = True
self._wtop = self.layout_parent
def set_data(self, dataitem, default_open=None, **opts):
""" this callback receives data from the meqbrowser, when the
user has requested a plot. It decides whether the data is
from a VellSet or visu data record, and after any
necessary preprocssing forwards the data to one of
the functions which does the actual plotting """
_dprint(3, "** in pylab_plotter:set_data callback")
if not has_pylab:
Message = "Matplotlib does not appear to be installed so no plot can be made."
cache_message = Qt.QLabel(Message, self.wparent())
# cache_message.setTextFormat(Qt.RichText)
self._wtop = cache_message
self.set_widgets(cache_message)
self.reset_plot_stuff()
return
self._rec = dataitem.data
_dprint(3, "set_data: initial self._rec ", self._rec)
# if we are single stepping through requests, Oleg may reset the
# cache, so check for a non-data record situation
if self._rec is None:
return
if isinstance(self._rec, bool):
return
self.label = ""
# extra label, filled in if possible
# there's a problem here somewhere ...
if dmi_typename(self._rec) != "MeqResult": # data is not already a result?
# try to put request ID in label
rq_id_found = False
data_failure = False
try:
if self._rec.cache.has_key("request_id"):
self.label = "rq " + str(self._rec.cache.request_id)
rq_id_found = True
if self._rec.cache.has_key("result"):
self._rec = self._rec.cache.result
# look for cache.result record
if not rq_id_found and self._rec.has_key("request_id"):
self.label = "rq " + str(self._rec.request_id)
else:
#.........这里部分代码省略.........