I have the following plots embedded in a wxpython panel with a single x axis and 2 y axes.
#Draw graph on 2nd panel
self.p2.figure = matplotlib.pyplot.figure()
self.p2.axes = self.p2.figure.add_subplot(111)
self.p2.axes.plot(interval_graph_values,flow_graph_values,'b',linewidth=0.35)
self.p2.axes.set_xlabel('Time after start of event (Hours)', fontsize=8, fontweight='bold')
self.p2.axes.set_ylabel('Flow (cumecs)', fontsize=8, color = 'blue', fontweight='bold')
for t1 in self.p2.axes.get_yticklabels():
t1.set_color('blue')
t1.set_fontsize(8)
self.p2.axes.twinx()
self.p2.axes.twinx().plot(interval_graph_values, rainfall_graph_values, 'r', linewidth=0.35)
self.p2.axes.twinx().set_ylabel('Rainfall (mm)', fontsize=8, color='red', fontweight='bold')
for t1 in self.p2.axes.twinx().get_yticklabels():
t1.set_color('red')
t1.set_fontsize(8)
self.p2.canvas = FigureCanvas(self.p2, -1, self.p2.figure)
#self.p2.toolbar = NavigationToolbar(self.p2.canvas)
self.p2.sizer = wx.BoxSizer(wx.VERTICAL)
self.p2.sizer.Add(self.p2.canvas, 1, wx.LEFT | wx.TOP | wx.GROW | wx.EXPAND)
#self.p2.sizer.Add(self.p2.toolbar, 0, wx.EXPAND)
self.p2.SetSizer(self.p2.sizer)
self.p2.Fit()
self.sp.SetMinimumPaneSize(360)
Data is pretty simple hydrometric stuff - interval_graph_values = [0.25, 0.5, 0.75...], flow_graph_values = [0.123, 0.191, 0.111...], rainfall_graph_values=[0, 0, 0.1...]
On mouse click events I want to retrieve event.ydata from the left hand axis, but I keep getting event data from the right axis instead.
I've tried playing with set_zorder() but that just seems to hide whichever axis has the lowest z_order value.
Is there a way of specifying which axis the mouse event should use?
*Sorry in advance if my code isn't the best, I'm trying to teach myself from scratch.
Thanks