国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Python+matplotlib+numpy實現在不同平面的二維條形圖

2020-02-16 11:25:08
字體:
來源:轉載
供稿:網友

在不同平面上繪制二維條形圖。

本實例制作了一個3d圖,其中有二維條形圖投射到平面y=0,y=1,等。

演示結果:

完整代碼:

from mpl_toolkits.mplot3d import Axes3Dimport matplotlib.pyplot as pltimport numpy as np# Fixing random state for reproducibilitynp.random.seed(19680801)fig = plt.figure()ax = fig.add_subplot(111, projection='3d')colors = ['r', 'g', 'b', 'y']yticks = [3, 2, 1, 0]for c, k in zip(colors, yticks):  # Generate the random data for the y=k 'layer'.  xs = np.arange(20)  ys = np.random.rand(20)  # You can provide either a single color or an array with the same length as  # xs and ys. To demonstrate this, we color the first bar of each set cyan.  cs = [c] * len(xs)  cs[0] = 'c'  # Plot the bar graph given by xs and ys on the plane y=k with 80% opacity.  ax.bar(xs, ys, zs=k, zdir='y', color=cs, alpha=0.8)ax.set_xlabel('X')ax.set_ylabel('Y')ax.set_zlabel('Z')# On the y axis let's only label the discrete values that we have data for.ax.set_yticks(yticks)plt.show()

腳本運行時間:(0分0.063秒)

總結

以上就是本文關于Python+matplotlib+numpy實現在不同平面的二維條形圖的全部內容,希望對大家有所幫助。感興趣的朋友可以繼續參閱本站其他相關專題,如有不足之處,歡迎留言指出。感謝朋友們對本站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 偏关县| 嵊州市| 阳西县| 望都县| 习水县| 红桥区| 巩义市| 台州市| 德格县| 普洱| 康马县| 宁武县| 固原市| 枣强县| 沭阳县| 阜宁县| 长宁区| 镶黄旗| 白沙| 仪陇县| 龙口市| 兴城市| 岚皋县| 公主岭市| 横山县| 锦屏县| 宿州市| 佛冈县| 达日县| 房产| 丽水市| 姜堰市| 绥中县| 彭阳县| 紫金县| 台中县| 泗水县| 临潭县| 济宁市| 西宁市| 行唐县|