Skip to content

Show decimal places and scientific notation on the axis #170

@zxdawn

Description

@zxdawn

Description

When the number is large, matplotlib will use e notation automatically. But, we usually use x10^{} in science paper.

Steps to reproduce

import proplot as plot
import numpy as np

state = np.random.RandomState(51423)
fig, axs = plot.subplots()
axs.format(ylim=(0, 5e10), ylocator=2e10)

Expected behavior:
scientific

Actual behavior:
e

Equivalent steps in matplotlib

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker

fig, ax = plt.subplots()
x = np.linspace(0, 5e10, 4)
# y = x**2
ax.plot(x)

f = mticker.ScalarFormatter(useOffset=False, useMathText=True)
g = lambda x,pos : "${}$".format(f._formatSciNotation('%1.10e' % x))
plt.gca().yaxis.set_major_formatter(mticker.FuncFormatter(g))

Proplot version

0.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions