2017-03-09 109 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:很高兴:) –