Last active
October 14, 2021 11:29
-
-
Save daliagachc/163762f8ac8bbf252312ae7410a5af64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from matplotlib import pyplot as plt | |
import matplotlib as mpl | |
f, ax = plt.subplots() | |
x = np.geomspace(.01, 100) | |
y = x | |
ax.plot(x, y) | |
ax.set_xscale('log') | |
def func(a, b): | |
b = int(np.log10(a)) | |
aa = f'{a:e}' | |
s = str(aa)[0] | |
ss = None | |
if int(s) < 8: | |
ss = f'$^{s}$' | |
return ss | |
# ax.xaxis.set_major_locator(mpl.ticker.LogLocator(base=10.0, numticks=25,subs=(.2,.3,.4,.5,.6,.7,1))) | |
lg = mpl.ticker.FuncFormatter(func) | |
# lg = mpl.ticker.LogFormatterExponent() | |
ax.xaxis.set_minor_formatter(lg) | |
ax.grid(which='both') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment