Python Forum

Full Version: Plot
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am working to understand python 3 and so far i've made serious improvements.
Try and bare with me because i feel like i am gonna be very annoying for the next days!
anyway
new problem...
i want to plot a function ...
the code is
import numpy as np
import matplotlib.pyplot as plt
from numpy import exp, sin  

def g(y):
    return exp(-y)*sin(4*y)

y = np.linspace(0, 4, 500)
values = g(y)
plt.figure()
plt.plot(y, values, 'r-')
plt.xlabel('$y$'); plt.ylabel('$g(y)$')
plt.title('Damped sine wave')
plt.show()
when it plots the graph the "zeros" in each axis are not at the beginning of the axis but a little bit to the left for the x axis and a little bit down for the y axis

Don't know if i used the right format in my thread about the code for python
...sorry about that to the administrators...i would be grateful if they could show me how to do it
...i read the "help" about using the right format but when i click on the bar about inserting the code it shows
 ! Am i supposed to write between the first [] and the second []? 
Not stupid ...i am just not familiar yet with the forum...
(Jul-20-2018, 01:27 PM)larri Wrote: [ -> ]Am i supposed to write between the first [] and the second []
yes. you did it right in this post

note that there are different tags - e.g. python (when post code), error (when post traceback), output (when post output), etc.
Thank you buran...it means a lot that you replied so fast.
Any suggestions perhaps about my problem?