gpt4 book ai didi

r - 有没有办法在绘图热图的右侧移动行标签?

转载 作者:行者123 更新时间:2023-12-04 14:21:36 24 4
gpt4 key购买 nike

我想知道是否可以在热图的右侧而不是左侧移动行标签,或者这不能在绘图中移动。

data<-as.matrix(mtcars)
data[upper.tri(data)] <- NA

library(plotly)
plot_ly(x=colnames(data), y=rownames(data), z = data,colors = colorRamp(c("red","green")), type = "heatmap") %>%
layout(
xaxis=list(tickfont = list(size = 30), tickangle = 45),
margin = list(l = 150, r = 50, b = 150, t = 0, pad = 4))

最佳答案

为此,我们可以使用 yaxis = list(side = "right") 并使用 colorbar = list(x = -0.4) 调整颜色条位置(您可以需要为您的特定图表稍微调整一下这个值):

plot_ly(x = colnames(data), y = rownames(data), z = data,
colors = colorRamp(c("red","green")),
type = "heatmap", colorbar = list(x = -0.4)) %>%
layout(xaxis = list(tickfont = list(size = 30), tickangle = 45),
yaxis = list(side = "right"),
margin = list(l = 150, r = 50, b = 150, t = 0, pad = 4))

enter image description here

关于r - 有没有办法在绘图热图的右侧移动行标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54161850/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com