Hi,
I need to represent a bar chart (left axis) and line chart (right axis) on the same plot.
ggplot() +
geom_bar( aes(x =data[['Var']], y =data[['Count']]), stat = "identity" , fill = "royalblue3", color= "royalblue3", alpha=0.6)+
geom_line( aes(x =data[['Var']], y =data[['line']], group=2, color='line') , stat = "identity") +
geom_point(aes(x =data[['Var']], y =data[['line']], group=2, color='line') , stat = "identity") +
geom_text( aes(x =data[['Var']], y =data[['line']], label = spec_transport[['line']], color='line'), size = 3, vjust = -1, stat = "identity") +
scale_y_continuous("lhs name", sec.axis = sec_axis(~./10, name = "rhs name"))
Somehow it doesnt understand that it needs to assign a line to the rhs axis. Cant find anything on ggplot documentation either. All the examples online say the same thing, which doesnt help to solve my issue.
Thanks