0

I have a plot that has a scatter. I was using previous answers that allowed me to click individual points of the scatter and display a label that I connected to each point (Found here and here). It worked well, but I now want to display a separate line on the same plot. I'm able to show the line, but now when I click on points near it, it displays a box about the line and not the scatter. I used zorder to have the scatter displayed on top but that doesn't change anything about which plot is selected when I click. Is there a way to specify which plot is on top in the mplcursors? I would think there would be a way if I wasn't using the loop to connect the scatter plot points with the labels, but I'm not sure if there's another way to do that. Alternatively, is there a way I could tell mplcursors to just ignore the line altogether?

Code snippet:

fig = plt.figure(figsize=(7,4))
ax = fig.add_subplot(1,1,1)

ax.plot(x_axis_2, y_axis_2, zorder=0) #This is the line

for i in self.full_dict['full_results']: #This is for the scatter plot
    ax.scatter(i[1],i[2],label='$[1D,2D]: {}$'.format(i[0]),zorder=5)

canvas = FigureCanvasTkAgg(fig, master=self.root)
canvas.draw()
canvas.get_tk_widget().grid(row=14,column=0,ipadx=40,ipady=10,columnspan=6)
datacursor(formatter='{label}'.format)

Working on scatter Problem near the line

jc990
  • 25
  • 5

0 Answers0