繁体   English   中英

如何在热图 r 中增加与主要 plot 的标签距离

[英]how to increase labels distance from main plot in heatmaply r

在 R 的交互式热图中有一个简单的问题。 我不知道如何在 heatmaply 中增加边距(x 和 y 标签与主图之间的距离)?

我想从热图中在ylab(省)中添加一点空间。 有人可以帮助我吗?

在此处输入图像描述

您可以通过使用heatmaply使用热图更改margins

由于您没有在问题中提供任何代码,我将使用示例 plot 使用mtcars并更改 y 轴边距

heatmaply(mtcars, margins = c(0, 200, 0, 0))

示例

如果您想将 y 轴标签从图表上移开,那将更加棘手。 目前,似乎没有办法做到这一点,但是,这里有一个解决方法。 目前有一种方法可以在heatmaply中移动 y 轴标签。 总的来说,这是一个糟糕的解决方法,但它似乎是目前最好的解决方案。

df <- mtcars
#extract the labels on the y axis. In this example mtcars y-axis labels are the row names
df2 <- as.data.frame(rownames(mtcars))
#you then have to add spaces to the end of the labels and then apply this to the dataframe you are using. 
rownames(df) <- paste0(df2$`rownames(mtcars)`, "            ")
#you can now run heatmaply on the new labels with added spaces
heatmaply(df)

示例2

总的来说, plotly有一些很棒的特性,但是它缺乏可调整性。 heatmaply的功能甚至比plotly还要少,因此更难以您想要的方式调整图表。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM