this is just a small problem that has been bugging me for a while.
I have a pandas dataframe consisting of all continuous variables. I want to draw a scatter plot (using matplotlib) for any chosen pair of variables, making use of the interactive widgets in Jupyter as well.
Let's say the data has 3 numeric columns: 'a','b', and 'c'.
So far I have these lines of codes:
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, as in they do churn out a scatter plot whenever I toggle with the drop-down boxes for x and y and select a pair of variables from the 3 variables available. However, the problem here is that previous plots churned out are not erased before a new plot is shown. In other words, matplotlib doesn't update the plot in the existing figure, but simply stack plots/figures on top of each other. So if I change the choice of variable pairs 10 times, I'll get 10 scatter plots, which isn't what I want.
Could anyone help me with this?
Thanks in advance.
ValueError: could not convert string to float: a
. From the answer below you see how a minimal reproducible example could look like. Please always use such minimal reproducible examples when asking questions. – ImportanceOfBeingErnest