Hello everyone.
I have specific tripcolor plots I want to handle and I want to be able to :
- put them in specific Axes
- plot a colorbar attached to them without knowing too much about colorbars meaning I want to be able to use pyplot.colorbar and not the seemingly more complicated Figure.colorbar
There are at least two ways one can do that (which is why I do not want to open a bug report since it is not really a bug) but I don’t know which one is “best practice” for what I want to do.
To be a little more precise, let us say I want to create some function draw(ax) which makes some kind of tripcolor plot in the Axes ax.
First way: use pyplot.sca + pyplot.tripcolor
def draw(ax, *args):
T, c = prepare_plot(*args)
plt.sca(ax)
plt.tripcolor(T, c)
Second way: use pyplot.sci + Axes.tripcolor
def draw(ax, *args):
T, c = prepare_plot(*args)
coll = ax.tripcolor(T, c)
plt.sci(coll)
Which one is the “expected” way to write this type of code? And if anyone can explain to me why the method of Axes version of the function does not set the image itself I’d be happy to learn. Why is Axes._sci a private function and pyplot.sci a public one?