Heatmap Plot in R using plot_ly
0
0
Entering edit mode
6.4 years ago

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 • 6.0k views
ADD COMMENT
0
Entering edit mode

Those parameters are not supported by plotly.

ADD REPLY
0
Entering edit mode

I searched for plotly but no luck with that.

ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

Thank you very much, it worked!

ADD REPLY

Login before adding your answer.

Traffic: 1736 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6