python 绘制3D视图
程序员文章站
2022-05-28 22:06:50
...
python 绘制三维图
需要调用的package
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import pylab
import plotly.offline as py
import plotly.graph_objs as go
定义plotmy3d函数
def plotmy3d(X,Y,Z,name):
data = [go.Surface(x=X,y=Y,z=Z)]
layout = go.layout(
title = name
autosize = Flase
width = 700
height = 700
margin = dict(
l= 65
r = 50
b = 65
t = 90
)
)
fig = go.Figure(data = data,layout = layout)
py.iplot(fig)
主函数
if __name__=='__main__':
plotmy3d(x,y,z, 'iceberg')
x,y,z以列表形式输入即可
总结
将绘图代码接口化,是自己学习的一份记录,如果能帮助到他人更好