I have to show the plot of a function with matplotlib
in python with logarithmic scale on the x axis and I wonder if there is any possibility to show x=0
? I'm aware that there is no log(0)
...
from matplotlib import pyplot as plt
def fkt(x,e):
y=np.sin(1/(x+e))
return y
def bild_fkt():
"""plottet die Funktion im Intervall[0,1] mit epsilon=1/5, 1/10, 1/20 mit linearer und
logarithmischer Skala """
plt.figure(figsize=(10,10))
x=np.linspace(0,1,100)
plt.subplot(211) #plots on linear scale
plt.plot(x, fkt(x,1/5), 'r', lw=2, label='e=1/5')
plt.plot(x, fkt(x,1/10), '-.', color='b', label='e=1/10')
plt.plot(x, fkt(x,1/20), ':', color='g', label='e=1/20')
plt.legend(loc=4)
plt.grid()
y=np.logspace(0,0.3010299957,100) #plots on logarithmic scale
plt.subplot(212)
plt.plot(y-1, fkt(y-1,1/5), 'r', lw=2, label='e=1/5')
plt.plot(y-1, fkt(y-1,1/10), '-.', color='b', label='e=1/10')
plt.plot(y-1, fkt(y-1,1/20), ':', color='g', label='e=1/20')
plt.legend(loc=4)
plt.grid()
plt.semilogx()
bild_fkt()
y
axis? You sayf(x) = 0
, which seems to meany = 0
. – quamrana Nov 29 '20 at 10:27log(0)
is undefined. So its not possible to plot that on a graph. Having0
on an axis is a different thing though. – Ragnar Nov 29 '20 at 10:51x = 0
on thex-axis
, the values get smaller and smaller, tending to0
, but never reaching it. On a linear scale, I consider the centre to be0
and there are negative values to the left and positive to the right. On a log scale, I consider the centre to be1
and fractional values to the left and multiples on the right. – quamrana Nov 29 '20 at 10:51