Python Forum
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plot
#1
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...
Reply
#2
(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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thank you buran...it means a lot that you replied so fast.
Any suggestions perhaps about my problem?
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020