Plotly.js:隐藏热图轴和图例

时间:2018-08-02 20:11:00

标签: javascript plotly heatmap

使用Plotly js作为热图,如何删除x轴,y轴和图例?在下面,您将找到我的代码

heatmap

var data = [
{
  z: z,
  type: 'heatmap',
  colorscale : [[0, 'rgb(0,0,255)']],
  opacity: 1

}
];


Plotly.plot('myDiv', data,  {
images: [
    {
      "source": "../images/img.png",
      "xref": "x",
      "yref": "y",
      "x": -1,
      "y": 50,
      "sizex": 51,
      "sizey": 51,
      "sizing": "stretch",
      "opacity": 1,
      "layer": "above"
    }
  ]

})

1 个答案:

答案 0 :(得分:0)

只需转到official plotly documentation,即可查找showing/hiding元素的相应属性。以下是您需要的属性。

下面是代码,更改了布局属性以适合您的要求。

var data = [
{
  z: z,
  type: 'heatmap',
  colorscale : [[0, 'rgb(0,0,255)']],
  opacity: 1

}
];


Plotly.plot('myDiv', data,  {
showlegend: false,
xaxis: {visible: false},
yaxis: {visible: false},
images: [
    {
      "source": "../images/img.png",
      "xref": "x",
      "yref": "y",
      "x": -1,
      "y": 50,
      "sizex": 51,
      "sizey": 51,
      "sizing": "stretch",
      "opacity": 1,
      "layer": "above"
    }
  ]

})