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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沈丘县| 应用必备| 阿鲁科尔沁旗| 会同县| 五大连池市| 称多县| 邹平县| 谢通门县| 承德市| 若尔盖县| 色达县| 昆山市| 策勒县| 吉林省| 洛浦县| 城步| 北安市| 息烽县| 尼木县| 建水县| 乐都县| 嘉义市| 军事| 屏东县| 横峰县| 绥德县| 樟树市| 东源县| 平定县| 文水县| 丹江口市| 阜新市| 两当县| 海伦市| 大新县| 马尔康县| 三台县| 微山县| 阜平县| 桐庐县| 舞阳县|