I am trying to plot a function z= sinx cosy over -pi to pi
This is what I'm hoping to get
This is the code I have written in an attempt to do the same:
import plotly.graph_objs as go
from scipy.linalg import toeplitz
x=np.linspace(-np.pi,np.pi,30)
z = [(np.sin(i)*np.cos(i)) for i in x]
fig = go.Figure(data=[go.Surface(x=x, y=x, z=toeplitz(z))])
fig.show()
plotly output that I'm getting
I have not been able to understand what 'grid' or '2d array' format I have to convert my z co-ordinate column data into for getting the right graph. Toeplitz was an attempt to do the same, but it seems symmetric unlike the required graph. Please help
I think I've got it, if you're facing similar issue you can refer/use the code below
import numpy as np
import plotly.graph_objs as go
f = lambda x,y: np.sin(x) * np.cos(y)
x = np.linspace(-np.pi, np.pi, 30)
y = np.linspace(-np.pi, np.pi, 30)
X,Y = np.meshgrid(x,y)
F = f(X,Y)
fig = go.Figure(data=[go.Surface(x=X, y=Y, z=F)])
fig.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.