Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attributes of AxesSubplot instances

Tags:

matplotlib

I am trying to understand the matplotlib API. I have seen many examples like this:

...
fig, (ax0, ax1) = plt.subplots(nrows=2)
ax1.spines['right'].set_visible(False)
...
ax1.xaxis.set_ticks_position('bottom')
...

(full example: http://matplotlib.org/examples/ticks_and_spines/spines_demo.html )

I understand what it does but I was unable to find in the API the spines and xaxis attributes of ax0 and ax1 that was used to retrieve the xaxis and the spines (although there is a documented get_xaxis() method but nothing for the spines). Of course now I know it for that particular case but are there other hidden attributes? Or perhaps I have not read the documentation correctly? Where these attributes come from? Maybe they were added by fig.subbplots? I would like to have a list of all public attributes for basic matplotlib objects. Do I really have to resort to the dir python builtin and guess the signification from the names?

like image 774
Olivier Esser Avatar asked Dec 29 '13 18:12

Olivier Esser


1 Answers

pyplot is a procedural style interface/abstraction over matplotlib's OO API. So pyplot internally creates/manages necessary objects required for plotting. Every object(e.g Line,Axis,Axes ) is an Artist for matplotlib. Each artist has attributes. Have a look over

http://matplotlib.org/users/artists.html

like image 67
Jagat Avatar answered Oct 21 '22 05:10

Jagat