How do I add a small filled circle or point to a countour plot in matplotlib?
You can easily draw the circle directly. Given 0 = x1**2 + x**2 - 0.6 it follows that x2 = sqrt(0.6 - x1**2) (as Dux stated). But what you really want to do is to transform your cartesian coordinates to polar ones. if you use these substitions in the circle equation you will see that r=sqrt(0.6) .
The pattern you are showing is in basic is 4 semi circles rotated 90 degrees clockwise. You can draw a semi circle by setting a limit for the equation x^2 + y^2 - 1 such that it produces a semi circle.
Here is an example, using pylab.Circle:
import numpy as np import matplotlib.pyplot as plt e = np.e X, Y = np.meshgrid(np.linspace(0, 5, 100), np.linspace(0, 5, 100)) F = X ** Y G = Y ** X fig = plt.figure() ax = fig.add_subplot(1, 1, 1) circ = plt.Circle((e, e), radius=0.07, color='g') plt.contour(X, Y, (F - G), [0]) ax.add_patch(circ) plt.show()
And here is another example (though not a contour plot) from the docs.
Or, you could just use plot
:
import numpy as np import matplotlib.pyplot as plt e = np.e X, Y = np.meshgrid(np.linspace(0, 5, 100), np.linspace(0, 5, 100)) F = X ** Y G = Y ** X fig = plt.figure() ax = fig.add_subplot(1, 1, 1) plt.contour(X, Y, (F - G), [0]) plt.plot([e], [e], 'g.', markersize=20.0) 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