question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Show decimal places and scientific notation on the axis

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
zxdawncommented, May 21, 2020

Wow, thanks! Totally switching to proplot now 😄

1reaction
lukelbdcommented, May 21, 2020

Newest version is officially out 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Show decimal places and scientific notation on the axis of a ...
To show decimal places and scientific notation on the axis of a matplotlib, we can use scalar formatter by overriding _set_format() method.
Read more >
Show decimal places and scientific notation on the axis of a ...
I have a y-axis that ranges from 1e+18 to 3e+18 (usually). I'd like to see each tick mark show values in scientific notation...
Read more >
Display numbers in scientific (exponential) notation
To quickly format a number in scientific notation, click Scientific in the Number Format box (Home tab, Number group). The default for scientific...
Read more >
Custom Formats for Numeric Display in Origin - YouTube
... axis labels, such as Degrees/Minutes/Seconds or add "pi". Convert data columns to percentage, scientific notation, or set decimal places ...
Read more >
Change Formatting of Numbers of ggplot2 Plot Axis in R ...
As you can see in Figure 2, we removed the scientific notation of the x-axis. The numbers are fully shown and after every...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found