0

How can one add additional labelled ticks to an axis? For example:

import matplotlib.pyplot as plt
import numpy as np

x = np.arange(0,10)  # random function to plot
y = np.exp(-x)

fig, axs = plt.subplots(1,1) 
axs.plot(x,y)
axs.set_yscale("log")
plt.show()

Output plot

I would like to have labelled y-ticks not only at the powers of 10, but also at, say, 0.15, 0.25,...

BigBen
  • 46,229
  • 7
  • 24
  • 40
reloh100
  • 65
  • 1
  • 8

1 Answers1

0

After axs.set_ycale("log") you can control yticks

import matplotlib.pyplot as plt
import numpy as np

x = np.arange(0,10)  # random function to plot
y = np.exp(-x)

fig, axs = plt.subplots(1,1) 
axs.plot(x,y)

axs.set_yscale("log")
axs.set_yticks([np.exp(-_) for _ in np.arange(0,10,.5)])
axs.set_yticklabels([f'10^{_}' for _ in np.arange(0,10,.5)])

plt.show()
user3474165
  • 171
  • 1
  • 3