matplotlib: Difference between Axes and AxesSubplot
ast
ast at invalid
Tue Apr 28 02:38:11 EDT 2020
Hello
It's not clear to me what the differences between
Axes and AxesSubplot classes are
AxesSubplot is a sub class of Axes
It is possible to draw in objects of both type with
plot, scatter ...
Axes object seems to be able to be inserted in AxesSubplot object
(It is strange because AxesSubplot is a sub class of Axes)
Here is a piece of code using both.
import matplotlib.pyplot as pyplot
figure = pyplot.figure()
axes = figure.add_subplot(111) # Renvoie un objet AxesSubplot, sous
classe de Axes
axes.scatter(range(5), [x ** 2 for x in range(5)])
axes.set_xlim(0, 4)
axes.set_xlabel('axe des x')
axes2 = figure.add_axes([0.3, 0.5, 0.3, 0.3]) # renvoie un objet Axes
axes2.patch.set_color('lightyellow')
axes2.plot(range(5), range(5))
and the figure it produces:
http://www.python-simple.com/img/img32.png
More information about the Python-list
mailing list