4

I have a time- and depth-varying function, simplified to:

def f(z,t):
    return np.exp(-z)*np.sin(t-z)

z = np.linspace(0,3000,num=3001)
t = np.arange(0,40000,4000)

I want to plot the the result for all z at each time step in t, resulting in something like this:

enter image description here

but I don't know how. I'm sure it's very simple, but I'm not used to doing this in python.

1 Answer 1

12
import matplotlib.pyplot as plt
import numpy as np

def f(z,t):
    return np.exp(-z)*np.sin(t-z)

z = np.linspace(0,5,3001)
t = np.arange(0,40000,4000)

for tval in t:
    plt.plot(z, f(z, tval))
plt.show()

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

ha, i feel like such a numpty. Thanks!
well, now you know how to do it, and that's all that's important.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.