keisukeのブログ

***乱雑です!自分用のメモです!*** 統計や機械学習の勉強と、読み物を書く練習と、備忘録用のブログ

matplotlib.axes.Axesのhelper methodsで作られたArtistsがどのcontainerに格納されるか

参考:Artist tutorial — Matplotlib 1.4.2 documentation

matplotlib.axes.Axes(一番良く使うArtists:subplotとか)のhelper methods(bar, plot, scatterなど)で作られたArtistsがどのcontainerに格納されるか:

Helper method Artist Container
Axes.annotate - text annotations Annotate Axes.texts
Axes.bar - bar charts Rectangle Axes.patches
Axes.errorbar - error bar plots Line2D and Rectangle Axes.lines and Axes.patches
Axes.fill - shared area Polygon Axes.patches
Axes.hist - histograms Rectangle Axes.patches
Axes.imshow - image data AxesImage Axes.images
Axes.legend - axes legends Legend Axes.legends
Axes.plot - xy plots Line2D Axes.lines
Axes.scatter - scatter charts PolygonCollection Axes.collections
Axes.text - text Text Axes.texts

`patches`だけちょっとわかりにくいが、長方形全般を格納するcontainer。


そもそもAxesがどういったcontainer(と属性)を持っているか、代表的なものを挙げると:

Axes attribute Description
Axes.artists A list of Artist instances
Axes.patch Rectangle instance for Axes background
Axes.collections A list of Collection instances
Axes.images A list of AxesImage
Axes.legends A list of Legend instances
Axes.lines A list of Line2D instances
Axes.patches A list of Patch instances
Axes.texts A list of Text instances
Axes.xaxis matplotlib.axis.XAxis instance
Axes.yaxis matplotlib.axis.YAxis instance

特に、`patch`と`patches`が紛らわしいので注意。
`patch`がAxesの背景の長方形(つまりひとつ)、`patches`がAxesが持ってる長方形のcontainer(つまりhist()とかで生成される長方形のリスト)。