python繪圖小記__python

來源:互聯網
上載者:User
# #!/usr/bin/env python# # -*- coding: UTF-8 -*-# """# @version: python2.7.8# @author: XiangguoSun# @contact: sunxiangguodut@qq.com# @file: 4.py# @time: 2017/2/16 11:07# @software: PyCharm# """import sysreload(sys)sys.setdefaultencoding('utf-8')import numpy as npimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d.art3d import Poly3DCollectiondef randrange(n, vmin, vmax):    return np.random.randint(vmin,vmax,n)def fun(ax,ben,color,n):    zl, zh = (0, 100)    x5 = randrange(n, 0, 100)    y5 = randrange(n, 0, 100)    z5=randrange(n,5,6)    ax.scatter(x5, y5, z5,s=50,c=color,marker='o')    poly3d = [[(0, 0, ben), (0, 100, ben), (100, 100, ben), (100, 0, ben)] ]    ax.add_collection3d(Poly3DCollection(poly3d, facecolors=color, linewidths=1, alpha=0.2))fig = plt.figure()ax = fig.gca(projection='3d')fun(ax,5,"red",10)fun(ax,50,"green",15)fun(ax,90,"blue",10)n = 50color="yellow"zl, zh = ( 0, 100)xa = randrange(n, 0, 100)ya = randrange(n, 0, 100)za = randrange(n, zl, zh)ax.scatter(xa, ya, za,s=50,c=color,marker='o')ax.set_xlabel('$x^{(1)}$',size=20)#$x^{(1)}$是Latex運算式ax.set_xlim3d(0, 100)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()



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.