mpound / pdrtpy

PhotoDissociation Region Toolbox Python module
GNU General Public License v3.0
6 stars 3 forks source link

pyplot functions plot to incorrect axes when colorbar = True in functions derived from PlotBase #89

Open abryant90 opened 11 months ago

abryant90 commented 11 months ago

When doing e.g. lrp.density(colorbar=True) and then calling pyplot functions like lrp._plt.scatter(x,y) to overplot details, these are instead plotted onto the colorbar Axes rather than the image.

This is a result of PlotBase._wcs_colorbar using AxesDivider.append_axes() to generate a colorbar axis. This axis then becomes the active axis when we make any future pyplot calls. The active axis can be reverted to the image axis by using plt.sca(ax)

In PlotBase._plot, this can be achieved by adding the following line to the if statement at line 376, below where _wcs_colorbar is called:

self._plt.sca(self._axis[axidx])