talgalili / heatmaply

Interactive Heat Maps for R Using plotly
377 stars 73 forks source link

Set legend box and change point type #184

Closed chabrault closed 5 years ago

chabrault commented 6 years ago

Hello, I'm using heatmaply with node_type="scatter".

Thank you for your function and sorry if the issue is not correctly written, I'm quite new on Github.

Best,

Charlotte

alanocallaghan commented 6 years ago

Sorry @chabrault I missed this. Can you post some example code please? I'd be happy to help in that case.

chabrault commented 6 years ago
# Create 2 matrices to plot
set.seed(1)
mat1 <- matrix(ncol=100, nrow=5, 0)
random.row <- sample(1:5, size=4, replace=TRUE)
random.col <- sample(1:100, size=20, replace=TRUE)
mat1[random.row, random.col] <- 1

set.seed(2)
mat2 <- matrix(ncol=100, nrow=5, 0)
random.row <- sample(1:5, size=4, replace=TRUE)
random.col <- sample(1:100, size=20, replace=TRUE)
mat2[random.row, random.col] <- 1

# Plot
library(heatmaply)
(plot.mat1 <- heatmaply(mat1, dendogram="none", Rowv=NA, Colv=NA, showticklabels = c(F,T), 
          col=c("lavender", "turquoise"), scale="none",
          node_type = "scatter", grid_size = 3, hide_colorbar = TRUE))

(plot.mat2 <- heatmaply(mat2, dendogram="none", Rowv=NA, Colv=NA, showticklabels = c(F,T), 
                        col=c("orange", "brown"), scale="none",
                        node_type = "scatter", grid_size = 3, hide_colorbar = TRUE))

# Plot together
subplot(plot.mat1, plot.mat2, nrows=2)

Some code to produce 2 matrices which look like mine. I'd like to put a legend box for colors I used (lavender, turquoise, orange and brown) and to change the point shape (I can only change the size with grid_size, the shape is always a crescent).

Thank you !

alanocallaghan commented 6 years ago

Thanks! This is indeed possible within plotly and/or heatmaply but not necessarily straightforward. I'll try to put together a code example and if possible expose the functionality within heatmaply directly. Cheers

alanocallaghan commented 6 years ago

Although I would note that for me, the shape is a circle. Perhaps the window is so small that the circles overlap?

talgalili commented 5 years ago

Are there plans to introduce this to heatmaply? If not, can we close this issue?

alanocallaghan commented 5 years ago

I think it's quite tricky as we'd have to pass in extra data to map to point shape etc. It also seems a bit of a niche application. I'd vote close but happy to see re-opened for a PR