0

Let me first say I've never studied matplotlib and pyplot organically. I've been able to employ these fantastic tools to some success however without developing a big picture of how things are supposed to be used. One of the thing that confuse me the most is the use of axes instances.

In many occasions I have found solutions to a particular problem which make use of axes or do not.

Example: one can set ticks to the x-axis through matplotlib.pyplot.xticks without using axes or through matplotlib.axes.Axes.set_xticks.

I usually try to avoid the use of axes. However there are times at which this seems to not be possible. For example when trying to use subplots with shared axis.

Can someone help me to shed some light on this subject? When am i supposed to use axes? When should I not?

Thanks.

deppep
  • 135
  • 1
  • 1
  • 7
  • See [this post](https://stackoverflow.com/questions/37970424/what-is-the-difference-between-drawing-plots-using-plot-axes-or-figure-in-matpl), especially the second answer – JohanC Mar 24 '20 at 18:13
  • You should just start at the first [Tutorial](https://matplotlib.org/3.1.1/tutorials/index.html) and work your way through them (practicing the examples) it will give you a good feel for *how it works*. Also take the time to visit the links in the Tutorial and peruse what is there before going back to the tutorial. – wwii Mar 24 '20 at 18:38
  • 1
    There is no universal answer to when you *should* use which of the two options. Since `pyplot` does not provide all options, you sometimes need to work with the axes object directly. Note however, that you can get the current axes at any times via `plt.gca()`, so there is essentially no difference between the two approaches. – ImportanceOfBeingErnest Mar 24 '20 at 19:04

0 Answers0