How To Plot Heatmap With Multiple Categories In A Single Cell With Ggplot2?
1
4
Entering edit mode
10.7 years ago
Gahoo ▴ 270

How to plot heatmap with multiple categories in a single cell with ggplot2? Heatmap plot of categorical variables could be done with this code

#data 
datf <- data.frame(indv=factor(paste("ID", 1:20),
    levels =rev(paste("ID", 1:20))), matrix(sample(LETTERS[1:7], 400, T), ncol = 20))



library(ggplot2); 
library(reshape2)
# converting data to long form for ggplot2 use

datf1 <- melt(datf, id.var = 'indv')

ggplot(datf1, aes(variable, indv)) + geom_tile(aes(fill = value),
   colour = "white")  +   scale_fill_manual(values= rainbow (7))

The codes came from here: http://rgraphgallery.blogspot.com/2013/04/rg54-heatmap-plot-of-categorical.html

But what about multiple categories in a single cell like this? Is it possible to use triangle or other shape as a cell?

http://postimg.org/image/4dudrv0nz/

http://postimg.org/image/4dudrv0nz/

r heatmap • 8.6k views
ADD COMMENT
0
Entering edit mode

It interesting task does anybody figure out how to do it ????

ADD REPLY
0
Entering edit mode
10.7 years ago

Take a look at geom_polygon.

ADD COMMENT
0
Entering edit mode

I've thought of that. But I don't know how to properly caclulate the correct coordinates of ploygon points. I prefer to write a function works like geom_tile using geom_polygon which can solve coordinates automatically.

ADD REPLY
0
Entering edit mode

Your question is probably more likely to get a useful answer on Stack Overflow. I think the ggplot2 developer hangs out there.

ADD REPLY

Login before adding your answer.

Traffic: 2161 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