I have a function f(x,t) = cos(t)*t + x
and i want to display the change of the result over the width x
and time t
at discretised time steps t_i
and discretised width steps x_j
.
Now I am a while here on SX and feel really embarrassed to only can post such little code or in other words nothing (since nothing worked I have done...): Nevertheless if someone has the time to help, I`d appreciate it.
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as pyplot
from astropy.io.ascii.latex import AASTex
def func(xi, ti):
res = np.cos(ti)*ti + xi
return res
timeSpacing = 100
timeStart = 0
timeEnd = 1
time = np.linspace(timeStart, timeEnd, timeSpacing)
widthSpacing = 300
widthStart = 0
widthEnd = 3
width = np.linspace(widthStart, widthEnd, widthSpacing)
resultList = [None]*timeSpacing
resultListInner = [None]*widthSpacing
for i, ithTime in enumerate(time):
for j, jthWidth in enumerate(width):
aas = np.zeros_like(width)
aas.fill(ithTime)
resultListInner[j] = ithTime, jthWidth, func(jthWidth, aas)
resultList[i] = resultListInner
So how do I correctly index the list and array and plot my data using matplotlib?
My plot should look like this:
where in my case the aperature should be the width x
, the sky annulus is my time t
and the RMS is my func(x,t)
.
y=cos(t)*t
will be an oscillation within a wedge envelope, and addingx
withy=cos(t)*t+x
will just add an offset. The offset is so obvious that I can't see why you'd want to plot 300 of these: it will cause cause a whole lot of clutter for very little information. And why do you callx
a "width"? Or, maybe easier, can you show a sketch of what you'd like the plot to look like? – tom10 19 hours agox
) and the time (t
). I will add a example picture what I want my plot to look like. – user69453 19 hours ago