用 Plotly 画个球面的参数方程
{ x = cos ( t ) sin ( s ) y = sin ( t ) sin ( s ) z = cos ( s ) , t ∈ [ 0 , 2 π ] , s ∈ [ 0 , π ] \left\{\begin{aligned} &x=\cos(t)\sin(s)\\ &y=\sin(t)\sin(s)\\ &z=\cos(s)\\ \end{aligned}, t\in [0,2\pi],s\in [0,\pi]\right. ⎩ ⎨ ⎧x=cos(t)sin(s)y=sin(t)sin(s)z=cos(s),t∈[0,2π],s∈[0,π]
import numpy as np
import plotly.graph_objs as go
cl="#000000"
bk="#000077"
a=np.linspace(0,2*np.pi,61)
b=np.linspace(0,np.pi,61)
s,t=np.meshgrid(a,b)
x=np.cos(s)*np.sin(t)
y=np.sin(s)*np.sin(t)
z=np.cos(t)
C={"z": {"show":False, "start":-1,"end":1,
"size":0.2,"usecolormap":False,"project_z":False,"highlightcolor":"limegreen"}}
D=go.Surface(x=x,y=y,z=z,opacity=1,surfacecolor=y, contours={ 'z':{'show': False }},colorscale="ylorrd")
L=go.Layout(width=640,height=640,plot_bgcolor=bk,paper_bgcolor=bk,
xaxis=dict(showgrid=False), # 不显示x轴网格
yaxis=dict(showgrid=False), # 不显示y轴网格
title={'text': '中秋快乐', # 标题文本
'font': {'color':'yellow', # 标题颜色设置为红色
'size': 35 # 标题字体大小
}
},
scene={'camera_eye': {"x": 1, "y": -2, "z":1},
"aspectratio": {"x": 1, "y": 1, "z": 1},
'bgcolor':bk,
'xaxis':{"backgroundcolor":bk,'gridcolor':bk,'linecolor':bk,'tickcolor':bk,'zerolinecolor':bk},
'yaxis':{"backgroundcolor":bk,'gridcolor':bk,'linecolor':bk,'tickcolor':bk,'zerolinecolor':bk},
'zaxis':{"backgroundcolor":bk,'gridcolor':bk,'linecolor':bk,'tickcolor':bk,'zerolinecolor':bk}}
# 这一堆颜色最重要了, 用于抠掉网格颜色
)
F=go.Figure(data=D,layout=L)
F.write_html('index.html')
标签:cos,False,中秋,bk,go,快乐,Plotly,np,sin
From: https://blog.csdn.net/serpenttom/article/details/142313575