如何设置两个包含热图的水平子图,以使它们不共享色标? [英] How to setup Plotly two horizontal subplots containing heatmaps so that they don't share a colorscale?

查看:189
本文介绍了如何设置两个包含热图的水平子图,以使它们不共享色标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个热点图.它们的值完全不同,因此不应共享色标.我尝试创建一个带有两个子图(水平排列)的绘图图,并将每个热图放入一个子图中.但是,两个热图在右侧的热图右侧共享相同的色标.色标显示两组相互重叠的标签.我想看到的是,有两个色标,每个热图的右边都有一个色标.

I have two heatmaps. Their values are in totally different scale, so should not share a colorscale. I tried to create a plotly figure w/ two subplots (arranged horizontally) and put each of my heatmaps into one of the subplot. However, the two heatmap shares the same colorscale to the right of the heatmap on the right. The colorscale show two sets of labels overlapped w/ each other. What I'd like to see is that there are two colorscales, one to the right of each heatmap.

我的代码如下.有人在这里看到问题吗?

My code is below. Anyone seeing a problem here?

fig = plotly.tools.make_subplots(rows=1, cols=2)

fig.append_trace(mm, 1, 1)
fig.append_trace(sm, 1, 2)

plotly.offline.iplot(fig)

我试图将share_xaxesshare_yaxes显式设置为False.没有帮助.

I have tried to set share_xaxes and share_yaxes to False explicitly. Didn't help.

推荐答案

您可以指定x 位置,请参见下面的示例.

You could specify the x position of the colorbar explicitly, see the example below.

笔记本上的数字看起来更好,也许还应该移动正确的图?

The figure looks better in the notebook, perhaps one should also move the right plot?

import plotly.plotly as py
import plotly.graph_objs as go
import plotly
plotly.offline.init_notebook_mode()

mm = go.Heatmap(
        z=[[1, 20, 30],
           [20, 1, 60],
           [30, 60, 1]],
        colorbar = dict(x=0.45), 
    colorscale='Viridis'
    )
sm = go.Heatmap(
        z=[[1, 2, 3],
           [2, 1, 6],
           [3, 6, 1]]
    )
fig = plotly.tools.make_subplots(rows=1, cols=2)
fig.append_trace(mm, 1, 1)
fig.append_trace(sm, 1, 2)

plotly.offline.iplot(fig)

这篇关于如何设置两个包含热图的水平子图,以使它们不共享色标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆