I would like to calculate several functions including ln(x)
on an interval going from 1 to 10. However, I would like to plot on an interval of x
ranging from x[-1, 10]
.
So far, I could not modify the ticks as I want, the labels are following the size of my ln(x)
rather than the value of x
itself:
axiss = np.linspace(-1,10,12)
x = np.linspace(-1, 10, 1002)
s = int(np.where(x == 1)[0])
fig, ax = plt.subplots()
ax.plot(np.log(x[s:-1]), label='ln(x)')
ax.plot(1/x[s:-1], label='1/x')
ax.plot(-1/(x[s:-1]**2), label='-1/x2')
ax.plot(2/(x[s:-1]**3), label='2/x3')
ax.legend()
ax.set_xlim(-100, 1000)
ax.set_xticklabels(axiss)
How could I do to define a range for my x-axis, but only calculate the functions on a part of it ?
I tried:
ax.plot(x, np.log(x[s:-1]), label='ln(x)')
but of course I have a length issue.
Thank you !
ps: yes I already searched online for ways to do it, asking here is the last resort that I have
question from:
https://stackoverflow.com/questions/65926352/how-to-extend-non-log-x-axis-of-lnx-plot 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…