proplot icon indicating copy to clipboard operation
proplot copied to clipboard

Better Scientific notation for 1*10^n

Open zxdawn opened this issue 3 years ago • 4 comments

Description

Usually, the 1 before 10^n is omitted. For example, 1x10^2 can be written as 10^2.

Steps to reproduce

import proplot as pplt

fig, axs = pplt.subplots()

axs.format(xlim=(1, 1e4), xscale='log', xformatter='sci')

Expected behavior: [What you expected to happen]

1 is shown as 10^0, 1x10^1 is shown as 10^1 ...

Actual behavior: [What actually happened]

image

Proplot version

Paste the results of import matplotlib; print(matplotlib.__version__); import proplot; print(proplot.version)here.

3.5.1
0.9.5.post202

zxdawn avatar Feb 12 '22 14:02 zxdawn

I guess this is what you need

axs.format(xlim=(1, 1e4), xscale='log', xformatter='log')

Try using 'log' instead of 'sci'.

syrte avatar Feb 12 '22 17:02 syrte

I guess this one's a matter of taste. I can see why you'd prefer the consistency of 10^0... I think for the next version I'll change the default behavior to include the 10^0 but add a SciFormatter keyword argument that optionally removes it.

Indeed LogFormatter is probably more appropriate here since it's a log-axis and your major ticks are on exact powers of 10... we may change the default log axis formatter back to LogFormatter for the next version (see #332 for updates).

lukelbd avatar Feb 12 '22 19:02 lukelbd

We could also have SciFormatter automatically remove the leading 1 x for brevity (making the appearance of LogFormatter and SciFormatter identical in this situation), but I guess that would also be a problem with inconsistency... maybe will add another boolean keyword argument for doing that.

lukelbd avatar Feb 12 '22 19:02 lukelbd

@syrte Thanks! Don't know the method of xformatter='log' to use the matplotlib default.

@lukelbd Yes. Omitting 1x sounds good.

zxdawn avatar Feb 12 '22 19:02 zxdawn