国产探花免费观看_亚洲丰满少妇自慰呻吟_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實現在不同平面的二維條形圖的全部內容,希望對大家有所幫助。感興趣的朋友可以繼續參閱本站其他相關專題,如有不足之處,歡迎留言指出。感謝朋友們對本站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 河间市| 无极县| 永顺县| 罗定市| 凤翔县| 浦江县| 兴国县| 荆门市| 渭源县| 苍溪县| 阳西县| 靖安县| 河池市| 宁都县| 文昌市| 安康市| 繁峙县| 沂南县| 仁寿县| 孟州市| 邵阳市| 张家界市| 栖霞市| 平昌县| 固镇县| 海城市| 通辽市| 壤塘县| 土默特右旗| 邮箱| 阜平县| 兴仁县| 东乌珠穆沁旗| 那坡县| 石棉县| 安泽县| 修水县| 益阳市| 大埔县| 嘉峪关市| 沧源|