1

I am trying to do the following: plot two different datasets, ask the user which one is better, remove the bad one from the figure, and save the good plot. However, I can't find a way to do it with matplotlib. I found the cla() command, but even like that it keeps on deleting the whole figure... can someone give me a hand with this?

Here is how I am doing it.

fig=plt.figure() ax=fig.add_subplot(111) plot(something) ax2=fig.add_subplot(111) plot(other thing) cla() 

Thanks!

1 Answer 1

3

This plots two curves. Clicking on a curve deletes it.

import matplotlib.pyplot as plt import numpy as np sin = np.sin cos = np.cos pi = np.pi def delete(event): artist = event.artist artist.remove() event.canvas.draw() fig = plt.figure() ax = fig.add_subplot(111) x = np.linspace(0, 2*pi, 50) y = 2*sin(x) z = 2*cos(x) line1, = ax.plot(x,y) line2, = ax.plot(x,z) for artist in [line1, line2]: artist.set_picker(5) fig.canvas.mpl_connect('pick_event', delete) plt.show() 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.