I come to encounter a problem that using two different data with the help of second axis function as described in this previous post how-to-use-facets-with-a-dual-y-axis-ggplot.
I am trying to use geom_point and geom_bar but the since the geom_bar data range is different it is not seen on the graph.
Here is what I have tried;
point_data=data.frame(gr=seq(1,10),point_y=rnorm(10,0.25,0.1)) bar_data=data.frame(gr=seq(1,10),bar_y=rnorm(10,5,1)) library(ggplot2) sec_axis_plot <- ggplot(point_data, aes(y=point_y, x=gr,col="red")) + #Enc vs Wafer geom_point(size=5.5,alpha=1,stat='identity')+ geom_bar(data=bar_data,aes(x = gr, y = bar_y, fill = gr),stat = "identity") + scale_y_continuous(sec.axis = sec_axis(trans=~ .*15, name = 'bar_y',breaks=seq(0,10,0.5)),breaks=seq(0.10,0.5,0.05),limits = c(0.1,0.5),expand=c(0,0))+ facet_wrap(~gr, strip.position = 'bottom',nrow=1)+ theme_bw() as it can be seen that bar_data is removed. Is is possible to plot them together in this context ??
thx


geom_barand make yourlimitsgo down to 0 instead of starting at .1 (as bars start at 0).