I am trying to find the difference between add_artist method and add_patch but I can't figure out.
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.patches import Circle
matplotlib.use('TkAgg')
fig, ax = plt.subplots()
ax.add_patch(Circle((0.5, 0.5), 0.3))
plt.show()
And
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.patches import Circle
matplotlib.use('TkAgg')
fig, ax = plt.subplots()
ax.add_artist(Circle((0.5, 0.5), 0.3))
plt.show()
Give the exact same behaviour... Maybe these two methods are doing the same but I am not sure ? Which one do I need to use if I want to draw something ?
Kind regards,
add_patch
changes the data limits where asadd_artist
does not. For example, if you increase the radius to 0.6 in your MWE, and callax.autoscale_view()
beforeplt.show()
, then the x and y limits will be adjusted in the first plot but not in the second. – Thuthucydides