簡體   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