how to Combine a bar chart and line in single plot in R (from different data sources)?
Say I have two data sources as:
barData<-c(0.1,0.2,0.3,0.4) #In percentage
lineData<-c(100,22,534,52,900)
Note that they may not be in the same scale.
Can I plot both barData and LineData in one plot and make them good looking ?
I cant use ggplot in this case so this is not a duplicated question..
Something like the following:
barData<-c(1,2,3,4,5,6);lineData<-c(100,22,534,52,900, 1000);x <- barplot(barData)[, 1];y <- scales::rescale(lineData, to = range(barData));lines(x, y);axis(4, at = pretty(range(barData)), labels = pretty(range(lineData)))
? – lukeA