The easiest solution would be to put your legend on the right hand side of the plot (the default position) rather than put it on top. The idea is to display the legend vertically so that the values can be read easily. In order to achieve this, you just need to remove the line of code: theme(legend.position="top"):
library(reshape2)
library(ggplot2)
library(scales)
data<-c(22115,39435,19107,25921,47909,96496,51339,78338,453,800,326,523,1882,2446,597,1529,
709,824,131,293,2391,6334,2025,7072,646,1205,465,985)
data <- as.data.frame(matrix(data, ncol=7, byrow=T))
colnames(data) <- c("No_religion", "Christian", "Buddhist",
"Hindu","Jewish","Muslim","Sikh")
rownames(data) <- c("AB", "C1","C2","DE")
head(data)[,1:4]
data$Approximated.Social.Grade <- rownames(data)
data_m <- melt(data, id.vars=c("Approximated.Social.Grade"))
head(data_m)
p <- ggplot(data_m, aes(x=variable,y=Approximated.Social.Grade)) +
xlab("religion") + theme_bw() +
theme(panel.grid.major = element_blank()) +
theme(legend.key=element_blank()) +
theme(axis.text.x=element_text(angle=45,hjust=1, vjust=1)) +
geom_tile(aes(fill=value)) +
scale_fill_gradient(low = "#FFB6C1", high = "#CD5C5C")
p
