本文整理汇总了Python中matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg.pan方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2WxAgg.pan方法的具体用法?Python NavigationToolbar2WxAgg.pan怎么用?Python NavigationToolbar2WxAgg.pan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg
的用法示例。
在下文中一共展示了NavigationToolbar2WxAgg.pan方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pan
# 需要导入模块: from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg import pan [as 别名]
def pan(self, ev):
if wx.Platform == "__WXMAC__":
self.ToggleTool(self.wx_ids["Pan"], self.GetToolState(self.wx_ids["Pan"]))
NavToolbar.pan(self, ev)
示例2: InterpretationEditorFrame
# 需要导入模块: from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg import pan [as 别名]
class InterpretationEditorFrame(wx.Frame):
#########################Init Funcions#############################
def __init__(self,parent):
"""Constructor"""
#set parent and resolution
self.parent = parent
self.GUI_RESOLUTION=self.parent.GUI_RESOLUTION
#call init of super class
default_style = wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX | wx.RESIZE_BORDER | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN | wx.NO_FULL_REPAINT_ON_RESIZE | wx.WS_EX_CONTEXTHELP | wx.FRAME_EX_CONTEXTHELP
wx.Frame.__init__(self, self.parent, title="Interpretation Editor version:%s"%CURRENT_VERSION,style=default_style, size=(675*self.GUI_RESOLUTION,425*self.GUI_RESOLUTION))
self.Bind(wx.EVT_CLOSE, self.on_close_edit_window)
#setup wx help provider class to give help messages
provider = wx.SimpleHelpProvider()
wx.HelpProvider.Set(provider)
self.helper = wx.ContextHelp(doNow=False)
#make the Panel
self.panel = wx.Panel(self,-1,size=(700*self.GUI_RESOLUTION,450*self.GUI_RESOLUTION))
#set icon
self.SetIcon(self.parent.icon)
# icon = wx.Icon()
# icon_path = os.path.join(IMG_DIRECTORY, 'PmagPy.ico')
# if os.path.exists(icon_path):
# icon.CopyFromBitmap(wx.Bitmap(icon_path), wx.BITMAP_TYPE_ANY)
# self.SetIcon(icon)
self.specimens_list=self.parent.specimens
self.current_fit_index = None
self.search_query = ""
self.font_type = self.parent.font_type
#build UI and menu
self.init_UI()
self.create_menu()
#update with stuff
self.on_select_level_name(None)
def init_UI(self):
"""
Builds User Interface for the interpretation Editor
"""
#set fonts
FONT_WEIGHT=1
if sys.platform.startswith('win'): FONT_WEIGHT=-1
font1 = wx.Font(9+FONT_WEIGHT, wx.SWISS, wx.NORMAL, wx.NORMAL, False, self.font_type)
font2 = wx.Font(12+FONT_WEIGHT, wx.SWISS, wx.NORMAL, wx.NORMAL, False, self.font_type)
#if you're on mac do some funny stuff to make it look okay
is_mac = False
if sys.platform.startswith("darwin"):
is_mac = True
self.search_bar = wx.SearchCtrl(self.panel, size=(350*self.GUI_RESOLUTION,25) ,style=wx.TE_PROCESS_ENTER | wx.TE_PROCESS_TAB | wx.TE_NOHIDESEL)
self.Bind(wx.EVT_TEXT_ENTER, self.on_enter_search_bar,self.search_bar)
self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.on_enter_search_bar,self.search_bar)
self.search_bar.SetHelpText(dieh.search_help)
# self.Bind(wx.EVT_TEXT, self.on_complete_search_bar,self.search_bar)
#build logger
self.logger = wx.ListCtrl(self.panel, -1, size=(100*self.GUI_RESOLUTION,475*self.GUI_RESOLUTION),style=wx.LC_REPORT)
self.logger.SetFont(font1)
self.logger.InsertColumn(0, 'specimen',width=75*self.GUI_RESOLUTION)
self.logger.InsertColumn(1, 'fit name',width=65*self.GUI_RESOLUTION)
self.logger.InsertColumn(2, 'max',width=55*self.GUI_RESOLUTION)
self.logger.InsertColumn(3, 'min',width=55*self.GUI_RESOLUTION)
self.logger.InsertColumn(4, 'n',width=25*self.GUI_RESOLUTION)
self.logger.InsertColumn(5, 'fit type',width=60*self.GUI_RESOLUTION)
self.logger.InsertColumn(6, 'dec',width=45*self.GUI_RESOLUTION)
self.logger.InsertColumn(7, 'inc',width=45*self.GUI_RESOLUTION)
self.logger.InsertColumn(8, 'mad',width=45*self.GUI_RESOLUTION)
self.logger.InsertColumn(9, 'dang',width=45*self.GUI_RESOLUTION)
self.logger.InsertColumn(10, 'a95',width=45*self.GUI_RESOLUTION)
self.logger.InsertColumn(11, 'K',width=45*self.GUI_RESOLUTION)
self.logger.InsertColumn(12, 'R',width=45*self.GUI_RESOLUTION)
self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnClick_listctrl, self.logger)
self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK,self.OnRightClickListctrl,self.logger)
self.logger.SetHelpText(dieh.logger_help)
#set fit attributes boxsizers
self.display_sizer = wx.StaticBoxSizer(wx.StaticBox(self.panel, wx.ID_ANY, "display options"), wx.HORIZONTAL)
self.name_sizer = wx.StaticBoxSizer(wx.StaticBox(self.panel, wx.ID_ANY, "fit name/color"), wx.VERTICAL)
self.bounds_sizer = wx.StaticBoxSizer(wx.StaticBox(self.panel, wx.ID_ANY, "fit bounds"), wx.VERTICAL)
self.buttons_sizer = wx.StaticBoxSizer(wx.StaticBox(self.panel, wx.ID_ANY), wx.VERTICAL)
#logger display selection box
UPPER_LEVEL = self.parent.level_box.GetValue()
if UPPER_LEVEL=='sample':
name_choices = self.parent.samples
if UPPER_LEVEL=='site':
name_choices = self.parent.sites
if UPPER_LEVEL=='location':
name_choices = self.parent.locations
if UPPER_LEVEL=='study':
name_choices = ['this study']
self.level_box = wx.ComboBox(self.panel, -1, size=(110*self.GUI_RESOLUTION, 25), value=UPPER_LEVEL, choices=['sample','site','location','study'], style=wx.CB_DROPDOWN|wx.TE_READONLY)
self.Bind(wx.EVT_COMBOBOX, self.on_select_high_level,self.level_box)
self.level_box.SetHelpText(dieh.level_box_help)
self.level_names = wx.ComboBox(self.panel, -1, size=(110*self.GUI_RESOLUTION, 25), value=self.parent.level_names.GetValue(), choices=name_choices, style=wx.CB_DROPDOWN|wx.TE_READONLY)
#.........这里部分代码省略.........
示例3: pan
# 需要导入模块: from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg import pan [as 别名]
def pan(self, *args):
self.ToggleTool(self.wx_ids["Zoom"], False)
self.ToggleTool(self.ON_MARKRINGS, False)
self.ToggleTool(self.ON_MARKSPOTS, False)
NavigationToolbar2WxAgg.pan(self, *args)
示例4: pan
# 需要导入模块: from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg import pan [as 别名]
def pan(self, *args):
self.ToggleTool(self.wx_ids['Zoom'], False)
self.ToggleTool(self.ON_LABELPEAKS, False)
NavigationToolbar2WxAgg.pan(self, *args)
示例5: InterpretationEditorFrame
# 需要导入模块: from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg import pan [as 别名]
class InterpretationEditorFrame(wx.Frame):
#########################Init Funcions#############################
def __init__(self,parent):
"""Constructor"""
#set parent and resolution
self.parent = parent
self.GUI_RESOLUTION=self.parent.GUI_RESOLUTION
#call init of super class
wx.Frame.__init__(self, self.parent, title="Interpretation Editor",size=(675*self.GUI_RESOLUTION,425*self.GUI_RESOLUTION))
self.Bind(wx.EVT_CLOSE, self.on_close_edit_window)
#make the Panel
self.panel = wx.Panel(self,-1,size=(700*self.GUI_RESOLUTION,450*self.GUI_RESOLUTION))
#set icon
icon = wx.EmptyIcon()
icon_path = os.path.join(IMG_DIRECTORY, 'PmagPy.ico')
if os.path.exists(icon_path):
icon.CopyFromBitmap(wx.Bitmap(icon_path), wx.BITMAP_TYPE_ANY)
self.SetIcon(icon)
self.specimens_list=self.parent.specimens
self.current_fit_index = None
self.search_query = ""
self.font_type = self.parent.font_type
#build UI
self.init_UI()
#update with stuff
self.on_select_level_name(None)
def init_UI(self):
"""
Builds User Interface for the interpretation Editor
"""
#set fonts
FONT_WEIGHT=1
if sys.platform.startswith('win'): FONT_WEIGHT=-1
font1 = wx.Font(9+FONT_WEIGHT, wx.SWISS, wx.NORMAL, wx.NORMAL, False, self.font_type)
font2 = wx.Font(12+FONT_WEIGHT, wx.SWISS, wx.NORMAL, wx.NORMAL, False, self.font_type)
#if you're on mac do some funny stuff to make it look okay
is_mac = False
if sys.platform.startswith("darwin"):
is_mac = True
self.search_bar = wx.SearchCtrl(self.panel, size=(350*self.GUI_RESOLUTION,25) ,style=wx.TE_PROCESS_ENTER | wx.TE_PROCESS_TAB | wx.TE_NOHIDESEL)
self.Bind(wx.EVT_TEXT_ENTER, self.on_enter_search_bar,self.search_bar)
self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.on_enter_search_bar,self.search_bar)
# self.Bind(wx.EVT_TEXT, self.on_complete_search_bar,self.search_bar)
#build logger
self.logger = wx.ListCtrl(self.panel, -1, size=(350*self.GUI_RESOLUTION,475*self.GUI_RESOLUTION),style=wx.LC_REPORT)
self.logger.SetFont(font1)
self.logger.InsertColumn(0, 'specimen',width=55*self.GUI_RESOLUTION)
self.logger.InsertColumn(1, 'fit name',width=45*self.GUI_RESOLUTION)
self.logger.InsertColumn(2, 'max',width=35*self.GUI_RESOLUTION)
self.logger.InsertColumn(3, 'min',width=35*self.GUI_RESOLUTION)
self.logger.InsertColumn(4, 'n',width=25*self.GUI_RESOLUTION)
self.logger.InsertColumn(5, 'fit type',width=60*self.GUI_RESOLUTION)
self.logger.InsertColumn(6, 'dec',width=35*self.GUI_RESOLUTION)
self.logger.InsertColumn(7, 'inc',width=35*self.GUI_RESOLUTION)
self.logger.InsertColumn(8, 'mad',width=35*self.GUI_RESOLUTION)
self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnClick_listctrl, self.logger)
self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK,self.OnRightClickListctrl,self.logger)
#set fit attributes box
self.display_sizer = wx.StaticBoxSizer(wx.StaticBox(self.panel, wx.ID_ANY, "display options"), wx.HORIZONTAL)
self.name_sizer = wx.StaticBoxSizer(wx.StaticBox(self.panel, wx.ID_ANY, "fit name/color"), wx.VERTICAL)
self.bounds_sizer = wx.StaticBoxSizer(wx.StaticBox(self.panel, wx.ID_ANY, "fit bounds"), wx.VERTICAL)
self.buttons_sizer = wx.StaticBoxSizer(wx.StaticBox(self.panel, wx.ID_ANY), wx.VERTICAL)
#logger display selection box
UPPER_LEVEL = self.parent.level_box.GetValue()
if UPPER_LEVEL=='sample':
name_choices = self.parent.samples
if UPPER_LEVEL=='site':
name_choices = self.parent.sites
if UPPER_LEVEL=='location':
name_choices = self.parent.locations
if UPPER_LEVEL=='study':
name_choices = ['this study']
self.level_box = wx.ComboBox(self.panel, -1, size=(100*self.GUI_RESOLUTION, 25), value=UPPER_LEVEL, choices=['sample','site','location','study'], style=wx.CB_DROPDOWN)
self.Bind(wx.EVT_COMBOBOX, self.on_select_higher_level,self.level_box)
self.level_names = wx.ComboBox(self.panel, -1, size=(100*self.GUI_RESOLUTION, 25), value=self.parent.level_names.GetValue(), choices=name_choices, style=wx.CB_DROPDOWN)
self.Bind(wx.EVT_COMBOBOX, self.on_select_level_name,self.level_names)
#mean type and plot display boxes
self.mean_type_box = wx.ComboBox(self.panel, -1, size=(100*self.GUI_RESOLUTION, 25), value=self.parent.mean_type_box.GetValue(), choices=['Fisher','Fisher by polarity','None'], style=wx.CB_DROPDOWN,name="high_type")
self.Bind(wx.EVT_COMBOBOX, self.on_select_mean_type_box,self.mean_type_box)
self.mean_fit_box = wx.ComboBox(self.panel, -1, size=(100*self.GUI_RESOLUTION, 25), value=self.parent.mean_fit, choices=(['None','All'] + self.parent.fit_list), style=wx.CB_DROPDOWN,name="high_type")
self.Bind(wx.EVT_COMBOBOX, self.on_select_mean_fit_box,self.mean_fit_box)
#show box
if UPPER_LEVEL == "study" or UPPER_LEVEL == "location":
show_box_choices = ['specimens','samples','sites']
if UPPER_LEVEL == "site":
show_box_choices = ['specimens','samples']
#.........这里部分代码省略.........
示例6: MatplotlibVisualizer
# 需要导入模块: from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg import pan [as 别名]
class MatplotlibVisualizer(StageVisualizer):
""""Subclass of StageVisualizer that utilizes matplotlib"""
def __init__(self, parent):
"""Create a StageVisualizer with matplotlib essentials"""
super(StageVisualizer, self).__init__(parent)
self.figure = matplotlib.figure.Figure()
self.axes = self.figure.add_subplot(111)
self.figure.subplots_adjust(top=1, bottom=0, right=1, left=0)
self.axes.get_xaxis().set_visible(False)
self.axes.get_yaxis().set_visible(False)
self.canvas = FigureCanvas(self, -1, self.figure)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
self.SetSizer(self.sizer)
self.toolbar = NavigationToolbar(self.canvas)
self.toolbar.pan()
self.toolbar.Hide()
self.Fit()
self.zoomer = self.zoom_factory(self.axes, base_scale=1.5)
self.canvas.Bind(wx.EVT_PAINT, self.on_paint)
def on_paint(self, evt):
"""
Redraws the canvas so we can see real time zooming
:param evt: For binding wx.EVT_PAINT to this function
:return: wx.PaintDC object so subclasses can call super.on_paint(evt)
instead of copy/pasting the contents of this function
"""
dc = wx.PaintDC(self.canvas)
# First, draw the graph with matplotlib
self.canvas.draw(dc)
return dc
def zoom_factory(self, ax, base_scale=2.):
"""
Handle zooming using the scroll wheel.
Original source: https://gist.github.com/tacaswell/3144287
"""
def zoom_fun(event):
# Get the current x and y limits
cur_xlim = ax.get_xlim()
cur_ylim = ax.get_ylim()
cur_xrange = (cur_xlim[1] - cur_xlim[0])*.5
cur_yrange = (cur_ylim[1] - cur_ylim[0])*.5
# Get event location
xdata = event.xdata
ydata = event.ydata
if event.button == 'up':
# Deal with zoom in
scale_factor = 1/base_scale
elif event.button == 'down':
# Deal with zoom out
scale_factor = base_scale
else:
# Deal with something that should never happen
scale_factor = 1
print event.button
# Set new limits - improved from original
ax.set_xlim([xdata - (xdata - cur_xlim[0])*scale_factor,
xdata + (cur_xlim[1] - xdata)*scale_factor])
ax.set_ylim([ydata - (ydata - cur_ylim[0])*scale_factor,
ydata + (cur_ylim[1] - ydata)*scale_factor])
# Force redraw
self.canvas.Refresh()
# Get the figure of interest
fig = ax.get_figure()
# Attach the call back
fig.canvas.mpl_connect('scroll_event', zoom_fun)
# Return the function
return zoom_fun