0

So I have three matplotlib subplots. I can use a pick event to pull off and re-plot the data in any one of the subplot. Is it possible to read the pick event and to find out what subplot number was selected?

7
  • Could you show us your code? Commented Dec 1, 2015 at 22:26
  • Unfortunately I cant do that because its just too big. Here are some relevant snippets that I can put in the question itself. Commented Dec 1, 2015 at 22:35
  • self.figure_canvas.mpl_connect('pick_event', self.select_axes) def select_axes(self, event): if event.mouseevent.button == 1: if isinstance(event.artist, matplotlib.axes.Axes): axes = event.artist for line in axes.get_lines(): plt.figure() plt.plot(line.get_xdata(), line.get_ydata()) plt.show() I cant seem to format this code correctly, basically I can pull off the plotted data but I cant tell which subplot it came from. Commented Dec 1, 2015 at 22:36
  • Please edit your question rather than dumping code in the comments. It's unreadable in this state. Commented Dec 1, 2015 at 22:39
  • You have the Axes object so you can probably do what ever you want with it. Failing that, you can use Axes as keys in dictionaries to map back to what ever you want. Commented Dec 1, 2015 at 23:10

1 Answer 1

2

Place the axes in a list or dictionary when creating. Then when a pick event has occurred, match the pick event axis to the dictionary.

Thank you all.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.