Matplotlib: how to remove only one outline element from an axis with other drawn elements?
I am trying to revitalize the estimation of the means and covariance of a mixture of Gaussians (Gaussian mixture models) for which I need to update the means and covariance plots at each iteration.
It's pretty easy to redraw the tools as I am using strings that have a method set_data
that I can call on every update. Unfortunately updating covariances is another story, as items are contour
represented as objects QuadContourSet
and don't have a method set_data
.
Here's an example of a toy:
import numpy as np
from matplotlib import mlab
# Toy data points (these are constant)
plt.plot(np.arange(-3,3,0.1), np.arange(-3,3,0.1))
x = np.arange(-5.0, 5.0, 0.1)
y = np.arange(-5.0, 5.0, 0.1)
X, Y = np.meshgrid(x, y)
# First toy iteration
Z1 = mlab.bivariate_normal(X, Y,
1, 1,
0, 0)
covariance1 = plt.contour(X, Y, Z1)
# Second toy iteration
Z2 = mlab.bivariate_normal(X, Y,
1, 1,
0, 3)
covariance2 = plt.contour(X, Y, Z2)
As in the real problem, I am drawing means, deviations and data points, I do not want to clear the whole axis.
The question is how to remove the first path covariance1
without removing other elements?
source to share