1515from mpl_toolkits .axes_grid1 import host_subplot
1616
1717
18- from matplotlib .lines import Line2D
19- from matplotlib .text import Text
18+
2019
2120from matplotlib .font_manager import FontProperties
2221from wx .lib .pubsub import pub as Publisher
@@ -59,11 +58,12 @@ def _init_ctrls(self, parent):
5958 self .canvas .SetFont (wx .Font (20 , wx .SWISS , wx .NORMAL , wx .NORMAL , False , u'Tahoma' ))
6059 self .isShowLegendEnabled = False
6160
62- self .canvas .mpl_connect ('figure_leave_event' , self ._onFigureLeave )
63- Publisher .subscribe (self .updateCursor , "updateCursor" )
61+
6462
6563 # Create the navigation toolbar, tied to the canvas
6664 self .toolbar = NavigationToolbar (self .canvas , allowselect = True )
65+ self .canvas .mpl_connect ('figure_leave_event' , self .toolbar ._onFigureLeave )
66+ Publisher .subscribe (self .updateCursor , "updateCursor" )
6767 self .toolbar .Realize ()
6868 self .seriesPlotInfo = None
6969
@@ -76,24 +76,13 @@ def _init_ctrls(self, parent):
7676 self ._setColor ("WHITE" )
7777
7878 left = 0.125 # the left side of the subplots of the figure
79- #right = 0.9 # the right side of the subplots of the figure
80- #bottom = 0.51 # the bottom of the subplots of the figure
81- #top = 1.2 # the top of the subplots of the figure
82- #wspace = .8 # the amount of width reserved for blank space between subplots
83- #hspace = .8 # the amount of height reserved for white space between subplots
79+
8480 plt .subplots_adjust (
8581 left = left #, bottom=bottom, right=right, top=top, wspace=wspace, hspace=hspace
8682 )
8783 plt .tight_layout ()
8884
89- #init hover tooltip
9085
91- # create a long tooltip with newline to get around wx bug (in v2.6.3.3)
92- # where newlines aren't recognized on subsequent self.tooltip.SetTip() calls
93- self .tooltip = wx .ToolTip (tip = 'tip with a long %s line and a newline\n ' )
94- self .canvas .SetToolTip (self .tooltip )
95- self .tooltip .Enable (False )
96- self .tooltip .SetDelay (0 )
9786
9887 #init lists
9988 #self.lines = {}
@@ -103,7 +92,7 @@ def _init_ctrls(self, parent):
10392 self .editseriesID = - 1
10493 self .editCurve = None
10594 self .editPoint = None
106- self .hoverAction = None
95+ # self.hoverAction = None
10796 self .selplot = None
10897
10998 self .cursors = []
@@ -117,28 +106,6 @@ def _init_sizers(self):
117106 self ._init_coll_boxSizer1_Items (self .boxSizer1 )
118107 self .SetSizer (self .boxSizer1 )
119108
120- '''
121- def changePlotSelection(self, datetime_list=[]):
122- cc= ColorConverter()
123- # k black, # r red
124- # needs to have graph first
125- selected = cc.to_rgba('r', 1)
126- unselected = cc.to_rgba('k', 0.1)
127- allunselected = cc.to_rgba('k', 1)
128- if self.editPoint:
129- colorlist=[allunselected] *len(self.editCurve.dataTable)
130- if len(datetime_list)>0:
131- for i in xrange(len(self.editCurve.dataTable)):
132- if self.editCurve.dataTable[i][1] in datetime_list:
133- colorlist[i]=selected
134- else:
135- colorlist[i]=unselected
136-
137- self.editPoint.set_color(colorlist)
138- #self.editPoint.set_color(['k' if x == 0 else 'r' for x in tflist])
139- self.canvas.draw()
140-
141- '''
142109 ## TODO 10/15/2014 Change function so that it will accept a list of datavalues. This will remove the need to loop through the values currently plotted and we would instead plot the list of datetimes and datavalues together.
143110
144111 def changePlotSelection (self , filtered_datetime ):
@@ -225,13 +192,13 @@ def stopEdit(self):
225192 self .lman = None
226193
227194 #self.canvas.mpl_disconnect(self.hoverAction)
228- try :
229- self .canvas .mpl_disconnect (self .pointPick )
230- self .pointPick = None
231- except AttributeError as e :
232- logger .error (e )
195+ # try:
196+ # self.canvas.mpl_disconnect(self.pointPick)
197+ # self.pointPick = None
198+ # except AttributeError as e:
199+ # logger.error(e)
233200
234- self .hoverAction = None
201+ # self.hoverAction = None
235202 self .xys = None
236203 self .alpha = 1
237204
@@ -280,10 +247,9 @@ def drawEditPlot(self, oneSeries):
280247 convertedDates = matplotlib .dates .date2num (dates )
281248 self .xys = zip (convertedDates , oneSeries .dataTable ['DataValue' ])
282249 self .toolbar .editSeries (self .xys , self .editCurve )
283- self .pointPick = self .canvas .mpl_connect ('pick_event' , self ._onPick )
250+ # self.pointPick = self.canvas.mpl_connect('pick_event', self._onPick)
284251 self .editSeries = oneSeries
285252
286-
287253 def _setColor (self , color ):
288254 """Set figure and canvas colours to be the same.
289255 :rtype : object
@@ -596,60 +562,60 @@ def make_patch_spines_invisible(self, ax):
596562 for sp in ax .spines .itervalues ():
597563 sp .set_visible (False )
598564
599- def _onMotion (self , event ):
600- """
601-
602- :type event: matplotlib.backend_bases.MouseEvent
603- :return:
604- """
605- try :
606- if event .xdata and event .ydata :
607- xValue = matplotlib .dates .num2date (event .xdata ).replace (tzinfo = None )
608- #self.toolbar.msg.SetLabelText("X= %s, Y= %.2f" % (xValue.strftime("%Y-%m-%d %H:%M:%S"), event.ydata))
609- #self.toolbar.msg.SetLabelText("X= %s, Y= %.2f" % (xValue.strftime("%b %d, %Y %H:%M:%S"), event.ydata))
610- self .toolbar .msg .SetLabelText ("X= %s, Y= %.2f" % (xValue .strftime ("%b %d, %Y %H:%M" ), event .ydata ))
611- self .toolbar .msg .SetForegroundColour ((66 , 66 , 66 ))
612- else :
613- self .toolbar .msg .SetLabelText ("" )
614- except ValueError :
615- pass
616-
617- def _onPick (self , event ):
618- """
619-
620- :param event:
621- :return:
622- """
623-
624- if isinstance (event .artist , Line2D ):
625- thisline = event .artist
626- xdata = thisline .get_xdata ()
627- ydata = thisline .get_ydata ()
628- ind = event .ind
629-
630- xValue = xdata [ind ][0 ]
631- yValue = ydata [ind ][0 ]
632- #tip = '(%s, %s)' % (xValue.strftime("%Y-%m-%d %H:%M:%S"), yValue)
633- #tip = '(%s, %s)' % (xValue.strftime("%b %d, %Y %H:%M:%S"), yValue)
634- tip = '(%s, %s)' % (xValue .strftime ("%b %d, %Y %H:%M" ), yValue )
635-
636- self .tooltip .SetTip (tip )
637- self .tooltip .Enable (True )
638- self .tooltip .SetAutoPop (10000 )
639-
640- elif isinstance (event .artist , Text ):
641- text = event .artist
642- #print "Picking Label: ", text.get_text()
643-
644- def _onFigureLeave (self , event ):
645- """Catches mouse leaving the figure
646-
647- :param event:
648- :return:
649- """
650-
651- if self .tooltip .Window .Enabled :
652- self .tooltip .SetTip ("" )
565+ # def _onMotion(self, event):
566+ # """
567+ #
568+ # :type event: matplotlib.backend_bases.MouseEvent
569+ # :return:
570+ # """
571+ # try:
572+ # if event.xdata and event.ydata:
573+ # xValue = matplotlib.dates.num2date(event.xdata).replace(tzinfo=None)
574+ # #self.toolbar.msg.SetLabelText("X= %s, Y= %.2f" % (xValue.strftime("%Y-%m-%d %H:%M:%S"), event.ydata))
575+ # #self.toolbar.msg.SetLabelText("X= %s, Y= %.2f" % (xValue.strftime("%b %d, %Y %H:%M:%S"), event.ydata))
576+ # self.toolbar.msg.SetLabelText("X= %s, Y= %.2f" % (xValue.strftime("%b %d, %Y %H:%M"), event.ydata))
577+ # self.toolbar.msg.SetForegroundColour((66, 66, 66))
578+ # else:
579+ # self.toolbar.msg.SetLabelText("")
580+ # except ValueError:
581+ # pass
582+ #
583+ # def _onPick(self, event):
584+ # """
585+ #
586+ # :param event:
587+ # :return:
588+ # """
589+ #
590+ # if isinstance(event.artist, Line2D):
591+ # thisline = event.artist
592+ # xdata = thisline.get_xdata()
593+ # ydata = thisline.get_ydata()
594+ # ind = event.ind
595+ #
596+ # xValue = xdata[ind][0]
597+ # yValue = ydata[ind][0]
598+ # #tip = '(%s, %s)' % (xValue.strftime("%Y-%m-%d %H:%M:%S"), yValue)
599+ # #tip = '(%s, %s)' % (xValue.strftime("%b %d, %Y %H:%M:%S"), yValue)
600+ # tip = '(%s, %s)' % (xValue.strftime("%b %d, %Y %H:%M"), yValue)
601+ #
602+ # self.tooltip.SetTip(tip)
603+ # self.tooltip.Enable(True)
604+ # self.tooltip.SetAutoPop(10000)
605+ #
606+ # elif isinstance(event.artist, Text):
607+ # text = event.artist
608+ # #print "Picking Label: ", text.get_text()
609+ #
610+ # def _onFigureLeave(self, event):
611+ # """Catches mouse leaving the figure
612+ #
613+ # :param event:
614+ # :return:
615+ # """
616+ #
617+ # if self.tooltip.Window.Enabled:
618+ # self.tooltip.SetTip("")
653619
654620class Cursor (object ):
655621 def __init__ (self , canvas , toolbar , ax , name ):
0 commit comments