proplot icon indicating copy to clipboard operation
proplot copied to clipboard

Setting scale after formatter in different calls resets the formatter

Open pguenth opened this issue 3 years ago • 1 comments

Description

If a formatter is set in one call to Figure.format() or Axes.format() another call to .format() setting the scale of the same axis resets the formatter to default.

Steps to reproduce

The following example produces three figures which show the problem under different circumstances.

import proplot as pplt

# Happens after setting the Formatter with Figure.format()
fig, axs = pplt.subplots(ncols=3, share=False)
fig.format(xlabel='xlabel does not vanish', yformatter='sci')
axs[0].format(ylabel='setting something unrelated') # Output formatter is 'sci'
axs[1].format(yformatter='sci', yscale='log') # Output formatter is 'sci'
axs[2].format(yscale='log') # Expected: output formatter is 'sci'. Actual: it is the default formatter
fig.savefig("test1.pdf")

# Happens also on two calls to Axes.format()
# The same behaviour can be reproduced for the x-axis
fig, axs = pplt.subplots(ncols=2, share=False)
fig.format(suptitle='Setting something unrelated')
axs[0].format(yformatter='sci', yscale='log') # set formatter and scale in one call
axs[1].format(yformatter='sci') # set the formatter first
axs[1].format(yscale='log') # and the scale in a second call -> formatter is reset
fig.savefig("test2.pdf")

Expected behavior: If the formatter is set once it should be persistent. In the example all y-axis should use the 'sci' formatter.

Actual behavior: When setting the scale in a second call the formatter is reset. In the example the rightmost subplots use the default formatter.

Equivalent steps in matplotlib

As far as I am concerned a method similar to the .format() methods of proplot is not available in matplotlib.

Proplot version

matplotlib: 3.5.1 proplot: 0.9.5

pguenth avatar Feb 12 '22 13:02 pguenth

Thanks, this should not happen if axis.isDefault_majfmt and axis.isDefault_majloc are being set properly. Will check

lukelbd avatar Feb 12 '22 18:02 lukelbd