日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

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

系統 1747 0

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

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

演示結果:

Python+matplotlib+numpy實現在不同平面的二維條形圖_第1張圖片

Python+matplotlib+numpy實現在不同平面的二維條形圖_第2張圖片

完整代碼:

            
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

# Fixing random state for reproducibility
np.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實現在不同平面的二維條形圖的全部內容,希望對大家有所幫助。感興趣的朋友可以繼續參閱本站其他相關專題,如有不足之處,歡迎留言指出。感謝朋友們對本站的支持!


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 遂平县| 凤城市| 永善县| 扎鲁特旗| 孟连| 肃南| 星座| 堆龙德庆县| 沂南县| 方正县| 含山县| 三江| 泸溪县| 嵊泗县| 古丈县| 荃湾区| 福建省| 左贡县| 七台河市| 巴塘县| 昔阳县| 伊川县| 莆田市| 获嘉县| 建宁县| 安庆市| 商河县| 岳阳县| 静宁县| 台东市| 扶风县| 中阳县| 内丘县| 广宗县| 潼关县| 北宁市| 西平县| 阿勒泰市| 安多县| 余干县| 宣武区|