2017-03-09 201 views
2

在等值線圖中,我可以給尺寸參數(https://plot.ly/python/reference/#contour-contours-size)指定每個輪廓線之間的等級。熱圖中是否有任何等價物?尺寸參數繪製熱圖

我有一個等高線圖,用戶可以指定範圍和二進制大小。默認範圍是數據的範圍,並且通過將該範圍除以12個箱子來計算箱尺寸。所以,在這個例子中的情節,範圍爲353.1至360.7,我們有0.6塊大小,我得到如下所示的等高線圖:

enter image description here

現在如果用戶輸入的範圍爲350〜370和1箱的尺寸,我們就會有20個二進制位,並且等高線圖是這樣的:

下面是熱圖,我得到了相同的數據與默認:

enter image description here

這裏是我所得到的,當我進入射程350至370和1箱尺寸:

enter image description here

我所尋找的是一個方法,使heapmap行爲像關於範圍和容器大小的等高線圖。

+0

你可以添加你想達到什麼樣的一個例子形象?你想要色階的步驟嗎? –

+0

我更新了問題,並添加了示例圖像和我的用例的解釋。 –

回答

1

您可以通過設置熱圖的zminzmax並添加自定義顏色範圍來實現所需的行爲。對火山的數據圖中的數據是從here採取:

您可以rel_minrel_max其指定用於色彩範圍值的上限和下限範圍和bin小號

注數玩。

var bin = 10; 
 
var rel_min = 100; 
 
var rel_max = 250; 
 

 
var colorscale = []; 
 
var color = Plotly.d3.scale.linear() 
 
    .domain([0, 0.5, 1]) 
 
    .range(["blue", "green", "red"]); 
 

 
for (var i = 0; i < bin; i += 1) { 
 
    colorscale.push([i/bin, color(i/bin)]); 
 
    colorscale.push([(i + 1)/bin, color(i/bin)]); 
 
} 
 

 
Plotly.newPlot('myDiv', [{ 
 
    z: heatmap, 
 
    zmin: rel_min, 
 
    zmax: rel_max, 
 
    type: 'heatmap', 
 
    colorscale: colorscale 
 
}])
<script src="https://cdn.plot.ly/plotly-latest.min.js"> 
 
</script> 
 
<script src="https://mbostock.github.io/protovis/ex/heatmap.js"></script> 
 
<div id="myDiv"></div>

+0

對不起,我剛剛嘗試這個 - 它完美的作品!非常感謝! –

+0

@LarryMartell:很高興:) –