I would like to use the pyplot.hold(True) since I want to draw a contour plot on a scatter plot. When I use the below code, it has the warning that pyplot.hold is deprecated. Is there any other option in Python 3 or I just ignore the warning? Thank you very much.
plt.scatter(X[:, 0], X[:, 1], s=150, c='b',
marker='x', linewidths=1)
plt.hold(True)
plt.contour(X1, X2, Z, np.power(10,(np.arange(-20,
0.1, 3)).T))
plt.hold(False)
Matplotlib does not erase any content from a figure by itself. The concept of hold is hence not necessary in matplotlib and will be removed.
Your code should therefore look like
plt.scatter(..)
plt.contour(..)
Possibly followed by plt.savefig(..) or plt.show().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With