This is just a small issue that has been listening to me for a while.
I have a pandas dataframe consisting of all contiguous variables. I want to draw a scatter plot (using matplotlib) for any selected pair of variables, using also interactive widgets in Jupyter.
Say the data has 3 numeric columns: 'a', 'b', and 'c'.
So far I have these lines of code:
def g(x,y):
plt.scatter(x, y)
interactive_plot = interactive(g, x=['a','b','c'], y=['a','b','c'])
interactive_plot
And they work fine, because they display scatterplots every time I switch with drop-down boxes for x and y and select a couple of variables from the three available variables. However, the problem here is that previous stories released are not erased before the new schedule is shown. In other words, matplotlib does not update the plot in the existing drawing, but simply stacks the graphics / drawings on top of each other. Therefore, if I change the choice of pairs of variables 10 times, I get 10 scatter diagrams, which is not what I want.
Can anyone help me with this?
Thanks in advance.
source
share