簡體   English   中英

顏色 map 在平面中的非均勻分布點處具有已知值

[英]color map with known values at non-uniformly spread points in plane

我正在嘗試獲得一種顏色 map 的熱圖,其平面中點的已知值分布不均勻(即不均勻或不呈網格形式)

import numpy as np

x = np.random.rand(100)
y = np.random.rand(100)
z = np.random.rand(100)

在這里,使用xyz ,我想要一個 plot 在點坐標(x[i], y[i])處顯示強度z[i]

我嘗試使用 matplotlib 的 pcolor 網格如下

import matplotlib.pyplot as plt
plt.figure()
plt.pcolormesh(x.reshape(10, 10), y.reshape(10, 10), z.reshape(10, 10))
plt.colorbar()
plt.show()

但這給出了以下錯誤,

 UserWarning: The input coordinates to pcolormesh are interpreted as cell centers, but are not monotonically increasing or decreasing. This may lead to incorrectly calculated cell edges, in which case, please supply explicit cell edges to pcolormesh.

我寧願使用tricontourf

In [11]: x = np.random.rand(10000)
    ...: y = np.random.rand(10000)
    ...: z = np.random.rand(10000)+3*x+2*y
    ...: plt.figure()
    ...: import matplotlib.tri as tri
    ...: plt.tricontourf(x, y, z)
    ...: plt.colorbar()
    ...: plt.show()
    ...: 

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM