Question: Heatmap Plot in R using plot_ly
0
gravatar for bandanaschapagain
5 months ago by
bandanaschapagain20 wrote:

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 • 401 views
ADD COMMENTlink modified 5 months ago by genomax59k • written 5 months ago by bandanaschapagain20

Those parameters are not supported by plotly.

ADD REPLYlink written 5 months ago by cpad011210k

I searched for plotly but no luck with that.

ADD REPLYlink written 5 months ago by bandanaschapagain20

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))
ADD REPLYlink written 5 months ago by cpad011210k

Thank you very much, it worked!

ADD REPLYlink written 5 months ago by bandanaschapagain20
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1687 users visited in the last hour