I'm trying to plot a line and a barchat using ggplot2
package but it's seems to be hard to get two different y-axis when using facet_grid()
function...
I'd like to add to my current plot a barchart with the Frequency of each product (variable Freq) in the data frame. Any help would be really awesome!!
temp = data.frame(Product=as.factor(c("L","P","41","43")),
Freq = c(0.2,0.8,0.7,0.3),
rate = c(14,17,12,20),
var= c("QUAL","QUAL","OCCU","OCCU"))
temp %>% ggplot() + theme_grey(base_size=20) +
geom_line(aes(x=Product, y=rate, group=var))+
geom_point(aes(x=Product, y=rate, group=var))+
geom_label( aes(x=Product,y=rate,label=paste0(rate,"%") )) +
facet_grid(.~ var, scales = "free") +
theme(legend.position="none", axis.text.x=element_text(angle=45, vjust=0.1)) -> p2