This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Heatmap Plot in R using plot_ly

Hi, I a beginner with R and I am trying to plot an interactive heatmap using plot_ly. Here is my code

plot_ly(x=colnames(data),y=rownames(data),z=data,type="heatmap")

The problem is the legends or the rownames are not shown completely. I followed the code from R-graph gallery and also found rowname not shown complete. Here is the link from R graph gallery where the row names are not shown completely. https://www.r-graph-gallery.com/215-interactive-heatmap-with-plotly/

I followed how to set the size of cell of heatmap.2 in R link and try the text, height and width options.

plot_ly(x=colnames(data),y=rownames(data),z=data,type="heatmap",lhei=c(1,8),lwid = c(1,4),cexRow=1,cexCol=1,margins=c(5,20))

It would be great help if anyone could help me out. Thank you.

r

Those parameters are not supported by plotly.

try this:

data=as.matrix(mtcars)
plot_ly(x=colnames(data), y=rownames(data), z = data, type = "heatmap") %>%
    layout(
        xaxis=list(tickfont = list(size = 30), tickangle = 45),
        margin = list(l = 150, r = 50, b = 150, t = 0, pad = 4))

0 answers

No answers yet.

Log in to answer this question.