I am new at python. I found this code for plotting $e^x$ in $[-2,2]$:
import matplotlib.pyplot as plt
import numpy as np
100 linearly spaced numbers
x = np.linspace(-2,2,100)
the function, which is y = e^x here
y = np.exp(x)
setting the axes at the centre
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.spines['left'].set_position('center')
ax.spines['bottom'].set_position('zero')
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
plot the function
plt.plot(x,y, 'y', label='y=e^x')
plt.legend(loc='upper left')
show the plot
plt.show()
How can I plot $y(x)=4e^{\frac{-118300}{x}}$ in $[3000,25000]$ in python with this code?
numpy.linspace(or its MATLAB cousin,linspace). – Sean Roberson Oct 22 '22 at 15:48