Overlay of two ggplots

Hi! Can anyone help me in my struggle to combine these two graphs into one? Ideally the coloured plot should be overlaid by the step plot, so that counts of "ox_=" are shown as steps on the coloured graph.

I have PLOT 1:
ggplot(subset(stw, !is.na(will)), aes(ox_0, fill=will)) +
geom_bar(position="fill") +
ggtitle("Willingness to repeat surgery per Oxford Knee Score at baseline") +
xlab("Preoperative Oxford Knee Score")+ ylab("")+
scale_y_continuous("", labels=c("0 %", "25%", "50%", "75%", "100%"))+
theme(
axis.text.y = element_text(size=12, color=1),
axis.title.x = element_text(size=15, color=1),
axis.text.x = element_text(size=12, color=1),
axis.title.y = element_text(size=15, color=1),
plot.title = element_text(hjust=0.5, size=16),
strip.text.x = element_text(size=12),
legend.text = element_text(size=13),
legend.title = element_text(size=15))+
scale_fill_manual("Would you repeat surgery?", values=col.traf, aesthetics = "fill")

and PLOT 2:
ggplot(subset(stw, !is.na(will)), aes(ox_0))+
stat_bin(geom="step", binwidth = 1)

have you tried + stat_bin(geom="step", binwidth = 1) onto the end of plot 1 ?

Thanks for your suggestion. It is not quite ok yet.... Do you know what happened here?
BR Anne
Attempt1

seems like you need to control them so they can be plotted in common scale.
Without a reprex, its hard to help.
but you can look at examples here; of the use of sec.axis

Thank you very much, I'll have a look at that.
BR Anne

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.