这篇文章将为大家详细讲解有关如何使用Python绘制3 d图形,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
Python主要应用领域有哪些
1,云计算,典型应用OpenStack.2,网前端开发,众多大型网站均为Python开发。3。人工智能应用,基于大数据分析和深度学习而发展出来的人工智能本质上已经无法离开python.4,系统运维工程项目,自动化运维的标配就是python + Django/flask.5,金融理财分析,量化交易,金融分析。6,大数据分析。
1、3 d表面形状的绘制
得到mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot  as plt import numpy  as np , 时间=fig plt.figure (), 时间=ax fig.add_subplot(111,投影=& # 39;3 d # 39;), , #,Make data 时间=u np.linspace (0, 2, *, np.pi,, 100), 时间=v np.linspace (0,, np.pi,, 100), 时间=x 10, *, np.outer (np.cos (u), np.sin (v)), 时间=y 10, *, np.outer (np.sin (u), np.sin (v)), 时间=z 10, *, np.outer (np.ones (np.size (u),, np.cos (v)), , #,Plot 从而,surface ax.plot_surface (x, y,, z,,颜色=& # 39;b # 39;), , plt.show ()
球表面,结果如下:
import matplotlib as mpl 得到mpl_toolkits.mplot3d import  Axes3D import numpy  as np import matplotlib.pyplot  as plt , mpl.rcParams [& # 39; legend.fontsize& # 39;],=, 10, , 时间=fig plt.figure (), 时间=ax fig.gca(投影=& # 39;3 d # 39;), 时间=theta np.linspace (4, *, np.pi,, 4, *, np.pi,, 100), 时间=z np.linspace (2,, 2,, 100), 时间=r z * * 2, +, 1, 时间=x r *, np.sin(θ), 时间=y r *, np.cos(θ), ax.plot (x, y,, z,,标签=& # 39;parametric 曲线# 39;), ax.legend (), , plt.show ()
这段代码用于绘制一个螺旋状三维曲线,结果如下:
得到mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot  as plt 得到matplotlib import  cm , 时间=fig plt.figure (), 时间=ax fig.gca(投影=& # 39;3 d # 39;), ,X,, Y, Z =, axes3d.get_test_data (0.05), cset =, ax.contour (X, Y,, Z, zdir=& # 39; Z # 39;,,抵消=-100,,提出=cm.coolwarm), cset =, ax.contour (X, Y,, Z, zdir=& # 39; X # 39;,,抵消=-40,,提出=cm.coolwarm), cset =, ax.contour (X, Y,, Z, zdir=& # 39; Y # 39;,,抵消=40岁,提出=cm.coolwarm), , ax.set_xlabel (& # 39; x # 39;), ax.set_xlim (-40, 40), ax.set_ylabel (& # 39; y # 39;), ax.set_ylim (-40, 40), ax.set_zlabel (& # 39; z # 39;), ax.set_zlim (-100, 100), , plt.show ()
绘制结果如下:
得到mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot  as plt import numpy  as np , 时间=fig plt.figure (), 时间=ax fig.add_subplot(111,投影=& # 39;3 d # 39;), 时间=x,, y np.random.rand (2, 100), *, 4, xedges,嘘,还以为;yedges =, np.histogram2d (x, y,,垃圾箱=4,范围=[[0,,4],[0,,4]]), , #,Construct arrays  for 从而anchor positions of , 16,酒吧只 注:#还以为;np.meshgrid  gives arrays 拷贝(纽约,nx), so use 我方表示歉意& # 39;f # 39;,用flatten xpos,, #,ypos column-major 拷贝订单只For numpy 祝辞=,1.7,could 我方表示歉意instead call meshgrid #,with 索引=& # 39;ij # 39;只 xpos, ypos =, np.meshgrid (xedges (: 1), +, 0.25, yedges (: 1), +, - 0.25), 时间=xpos xpos.flatten (& # 39; f # 39;), 时间=ypos ypos.flatten (& # 39; f # 39;), 时间=zpos np.zeros_like (xpos), , #,Construct arrays  with 从而dimensions for , 16,酒吧只 dx 0.5=,, *, np.ones_like (zpos), 时间=dy dx.copy (), 时间=dz hist.flatten (), , ax.bar3d (xpos, ypos, zpos,, dx, dy,, dz,,颜色=& # 39;b # 39;,, zsort=& # 39;平均# 39;), , null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null