# #!/usr/bin/env Python #-*-coding:utf-8-*-# "" "# @version: python2.7.8 # @author: Xiangguosun # @contact: Sunxian Gguodut@qq.com # @file: 4.py # @time: 2017/2/16 11:07 # @software: Pycharm # "" "Import sys reload (SYS) Sys.setdefaultenco
Ding (' utf-8 ') import NumPy as NP import Matplotlib.pyplot as PLT from Mpl_toolkits.mplot3d.art3d import poly3dcollection
def randrange (n, Vmin, Vmax): Return Np.random.randint (Vmin,vmax,n) def fun (Ax,ben,color,n): Zl, en = (0, 100) x5 = Randrange (n, 0) Y5 = Randrange (n, 0) Z5=randrange (n,5,6) Ax.scatter (X5, Y5, Z5,s=50,c=color,m Arker= ' o ') Poly3d = [[(0, 0, Ben), (0, Ben), (MB, Ben), (0, Ben)]] Ax.add_collection3d (poly3dcoll Ection (Poly3d, Facecolors=color, Linewidths=1, alpha=0.2)) FIG = plt.figure () ax = FIG.GCA (projection= ' 3d ') Fun (ax,5, "re D "," Fun (ax,50, "green",) Fun (ax,90, "Blue", "n" = color= "Yellow" Zl, en = (0) xa = randrange (n, 0, m) ya = Randrange (n, 0,) za= Randrange (N, Zl, en) ax.scatter (xa, ya, za,s=50,c=color,marker= ' o ') ax.set_xlabel (' $x ^{(1)}$ ', size=20) # $x ^{(1)}$ is latex expression ax.set_xlim3d (0) Ax.set_ylabel (' $x ^{(2)}$ ', size=20) Ax.set_ylim3d (0,100) Ax.set_zlabel (' $z $ ', size=20 ) Ax.set_zlim3d (0,100) plt.show ()