亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用三列向量繪制顏色圖?

如何使用三列向量繪制顏色圖?

叮當貓咪 2023-07-18 13:39:32
我有三個向量:X、Y 和 Coc。X 和 Y 是以米為單位的位置。我想使用 Python 在顏色圖中可視化 Coc。我想用下面的代碼繪制顏色圖import pandas as pdimport matplotlib.pyplot as plt    X=pd.read_csv('X.csv')    Y=pd.read_csv('Y.csv')    Coc=pd.read_csv('Coc.csv')        plt.pcolor(X,Y,Coc*1e6, cmap='jet');plt.clim((1e-17, 1e-1));plt.xlabel('x (metres)');plt.ylabel('y (metres)');cb1=plt.colorbar();plt.show()但我得到一個空圖。我做錯了什么或者有其他方法來可視化數據。數據 X、Y 和 Coc 在 url 中。https://drive.google.com/folderview?id=1w9f-wTlpgyUYBveZNeZvdcRrMgFR9jKB
查看完整描述

1 回答

?
慕森卡

TA貢獻1806條經驗 獲得超8個贊

您有 222 個條目,但只有 6 個不同的xy對。您無法pcolor根據此類數據創建繪圖。


Coc要繪制每對對應的分布xy,您可以迭代 6 對并kdeplot根據對應Coc值創建 。更改圖例的一個簡單方法是使用plt.legend(new_labels, title='Locations:').


import matplotlib.pyplot as plt

import numpy as np

import seaborn as sns


X = np.array([754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19, 754.285, 755.062, 756.754, 758.071, 758.195, 759.19])

Y = np.array([569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993, 569.503, 570.785, 571.896, 572.669, 574.231, 576.993])

Coc = np.array([3.96e-15,2.39e-15,8.5e-15,2.83e-14,7.59e-15,2.0287e-01,1.1584e-02,2.1402e-01,3.5672e-02,5.2448e-02,1.2968e-02,3.2069e-02,2.267e-02,2.553e-01,4.1874e-02,5.9223e-01,1.9305e-01,4.3572e-02,4.9312e-02,2.9767e-01,2.8906e-02,3.67e-14,1.4846e-02,9.2954e-03,1.e-14,3.73e-02,5.67e-15,5.92e-15,7.62e-15,1.3594e-02,2.3187e-02,1.5313e-02,2.6313e-02,1.2019e-02,5.3779e-02,2.0352e-02,8.21e-15,1.2439e-01,1.08e-14,8.32e-15,1.86e-14,1.13e-14,1.97e-14,8.75e-15,4.33e-15,1.6688e-02,1.3375e-02,7.7849e-03,1.5341e-02,6.44e-15,9.18e-15,5.3385e-02,3.4455e-02,2.3291e-02,2.7082e-02,3.1913e-02,1.24e-14,1.89e-14,4.67e-15,5.09e-15,1.08e-14,1.75e-14,1.12e-14,4.14e-15,3.54e-15,1.84e-15,1.315e-02,2.2633e-02,3.1406e-02,2.677e-02,3.61e-15,1.2997e-02,6.59e-15,2.62e-14,8.5e-15,1.2e-14,4.29e-15,5.06e-15,1.3807e-02,4.4542e-02,5.5308e-02,1.0526e-01,1.9305e-02,1.9241e-02,1.2328e-02,1.8143e-01,6.5041e-02,1.7483e-02,1.0189e-02,6.4138e-03,2.8158e-02,9.6417e-02,3.8939e-02,1.8071e-02,1.07e-14,4.7207e-02,9.424e-03,1.6424e-02,1.5549e-02,3.56e-15,1.2974e-02,1.4416e-02,2.81e-14,1.15e-14,9.34e-15,7.5394e-02,5.41e-15,1.3e-15,1.68e-14,6.8171e-02,3.7142e-01,1.29e-14,4.04e-15,3.6949e-02,8.29e-14,1.1353e-01,1.0511e-01,6.9931e-02,2.2165e-02,3.99e-15,7.5611e-02,7.2137e-02,6.5534e-02,1.1801e-01,7.3289e-02,1.2758e-01,9.65e-14,6.57e-14,4.06e-14,1.1855e-01,1.8555e-01,7.8953e-02,3.27e-14,1.34e-13,7.62e-14,4.5127e-01,2.15e-14,1.87e-14,3.9084e-02,5.8303e-02,2.5415e-02,1.1801e-01,1.0993e-02,2.8583e-02,8.5474e-02,1.4232e-01,4.5611e-03,5.7911e-02,2.3238e-02,5.4378e-02,4.17e-14,1.9012e-01,5.8091e-02,1.3003e-01,7.9366e-02,6.4835e-02,4.0271e-02,3.1583e-02,2.5052e-02,5.5835e-01,5.2339e-02,9.7333e-03,6.276e-03,3.6937e-02,2.5363e-02,1.2715e-02,2.869e-02,1.6557e-02,4.23e-14,7.85e-14,3.75e-15,3.88e-14,9.77e-14,2.4679e-01,2.63e-14,8.7e-15,3.8667e-02,2.28e-14,7.56e-15,1.6e-15,1.52e-14,1.65e-14,2.73e-14,2.72e-14,8.5802e-03,2.82e-14,1.86e-14,1.96e-14,1.1001e-01,3.32e-14,1.0628e-02,1.6313e-01,3.4518e-02,2.9333e-01,2.7339e-01,3.125e-01,2.7778e-01,6.3057e-01,2.e-14,3.1143e-02,1.9824e-02,7.4301e-02,1.43e-02,1.8405e-01,5.58e-14,1.45e-14,3.46e-15,1.36e-14,1.6e-14,3.65e-15,1.1232e-01,5.6927e-02,2.0913e-01,1.2839e-01,7.7758e-02,6.0391e-02,1.55e-16,1.0728e-02,1.4741e-02,1.1801e-02,4.2257e-03,9.5423e-03])


for x in np.unique(X):

    y = Y[X==x][0]

    sns.kdeplot(Coc[X==x], label=f'X={x} Y={y}')

legend_labels = ['New Orleans', 'Cartagena', 'Vienna', 'Pretoria', 'Beijing', 'Brisbane']

plt.legend(legend_labels)

plt.show()

http://img1.sycdn.imooc.com//64b625e60001709904660195.jpg

另一種方法可能是對Coc屬于每xy對的所有值進行排序:


for i, x in enumerate(np.unique(X)):

    y = Y[X==x][0]

    plt.plot(np.sort(Coc[X==x])[::-1], label=f'X={x} Y={y}')

plt.legend()

plt.margins(x=0.01)

plt.xlabel('<--------------------- highest Coc values                  lowest Coc values --------------------->')

plt.ylabel('Coc')

http://img1.sycdn.imooc.com//64b625f60001d92d11520430.jpg

查看完整回答
反對 回復 2023-07-18
  • 1 回答
  • 0 關注
  • 160 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號