本文整理匯總了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:
#.........這裏部分代碼省略.........