rez
rez

Reputation: 338

how to increase labels distance from main plot in heatmaply r

I have a simple issue in interactive heatmap in R. I couldn't figure out how to increase margins (distance between x and y labels with main plot) in heatmaply?

I want to add a little bit of space in ylab (province) from heatmap. Could anybody help me?

enter image description here

Upvotes: 1

Views: 508

Answers (1)

neuron
neuron

Reputation: 2049

You can change the margins with heatmaply by using margins

Since you did not provide any code in your question, I will use an example plot using mtcars and changing the y-axis margins

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

exmaple

If you want to move the y-axis labels away from the graph, then that will be trickier. Currently, there doesn't appear to be a way to do this, however, here is a workaround. There is currently now way to move the y-axis labels in heatmaply. Overall, this is a poor workaround but it appears to be the best solution as of right now.

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)

example2

Overall, plotly has some great features however it lacks in tuneability. heatmaply has even fewer features than plotly so it makes it even harder to tune your graph the way you want to.

Upvotes: 0

Related Questions