Show decimal places and scientific notation on the axis
See original GitHub issueDescription
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:
Actual behavior:
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:
- Created 3 years ago
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Wow, thanks! Totally switching to
proplot
now 😄Newest version is officially out 😄