Skip to content

Instantly share code, notes, and snippets.

@daliagachc
Last active October 14, 2021 11:29
Show Gist options
  • Save daliagachc/163762f8ac8bbf252312ae7410a5af64 to your computer and use it in GitHub Desktop.
Save daliagachc/163762f8ac8bbf252312ae7410a5af64 to your computer and use it in GitHub Desktop.
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