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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 景德镇市| 黄冈市| 石景山区| 德兴市| 郴州市| 甘南县| 东兴市| 宣化县| 永新县| 丰台区| 专栏| 东台市| 玉环县| 固原市| 景洪市| 常宁市| 江西省| 双柏县| 台安县| 神木县| 通山县| 英吉沙县| 博湖县| 徐州市| 孙吴县| 衡阳县| 鹤山市| 西安市| 游戏| 哈密市| 嵩明县| 拉萨市| 涟源市| 南郑县| 内黄县| 梅河口市| 泸西县| 博白县| 南丹县| 庐江县| 垫江县|