ggplot का उपयोग करके, मैं पैनल के साथ एक ग्राफ टाइल का प्रतिनिधित्व करना चाहता हूं, लेकिन प्रत्येक पैनल के लिए समान ऊंचाई टाइल के साथ। मैं इस ग्राफ है:geom_tile और facet_grid/facet_wrap
dataSta <- list(sites=rep(paste("S", 1:31),each=12), month=rep(1:12,31), value=round(runif(31*12, min=0, max=3000)), panel=c(rep("Group 1",16*12),rep("Group 2", 12*12), rep("Group 3", 3*12)))
library(ggplot2)
library(grid)
base_size <- 9
windows()
ggplot(data.frame(dataSta), aes(factor(month), sites)) +
geom_tile(aes(fill = value), colour = "black")+
facet_wrap(~panel, scale="free_y", nrow=3)+
theme_grey(base_size = base_size) +
labs(x = "",y = "") +
scale_x_discrete(expand = c(0, 0)) +
scale_y_discrete(expand = c(0, 0)) +
theme(legend.title = element_blank(),
axis.ticks = element_blank(),
axis.text.x = element_text(size = base_size *0.8, hjust = 0),
panel.margin = unit(0,"lines"),
strip.text = element_text(colour="red3", size=10, face=2))
लेकिन टाइल्स की ऊंचाई पैनल के बीच अलग है। मैं facet_grid इस्तेमाल करने की कोशिश:
windows()
ggplot(data.frame(dataSta), aes(factor(month), sites)) +
geom_tile(aes(fill = value), colour = "black")+
facet_grid(panel~., scales="free_y", space="free")+
theme_grey(base_size = base_size) +
labs(x = "",y = "") +
scale_x_discrete(expand = c(0, 0)) +
scale_y_discrete(expand = c(0, 0)) +
theme(legend.title = element_blank(),
axis.ticks = element_blank(),
axis.text.x = element_text(size = base_size *0.8, hjust = 0),
panel.margin = unit(0,"lines"),
strip.text = element_text(colour="red3", size=10, face=2))
टाइल्स की ऊंचाई के साथ समस्या हल हो गई है, लेकिन पैनल के लेबल (समूह 1 ... समूह 3) पैनल के शीर्ष पर नहीं हैं। क्या facet_grid के साथ पैनल लेबल की स्थिति बदलना संभव है? या facet_grid और facet_wrap गठबंधन? आपकी मदद के लिए धन्यवाद, और मेरी अंग्रेजी के लिए खेद है!
संभावित डुप्लिकेट: https://stackoverflow.com/a/32733035/7886302 – Undo