I've got data for prices and volumes of a good and I'd like to include information for both in a single plot. I've got it working so that it shows both, but volume happens to be much larger than prices for my data, so I need different scales for them.
Here's some example code that's representative of what I'm working with:
days = c(1:100)
price = rnorm(100,mean=2,sd=.2)
volume = rbinom(100, size=1000, prob=.2)
df = data.frame(days,price,volume)
Now, if I use
ggplot() + geom_bar(data=df, aes(x=days,y=volume), stat="identity") + geom_point(data=df, aes(x=days,y=price))
It almost does what I want (i.e. one single chart that has both) but since it has the same scale for both price and volume, you can't really tell the variation in prices. Prices go from about 1.5-2.5 while most volume is in the range of ~200.
So what I want is for prices to be scaled at something like 0-3 and volume to be scaled at something like 0-1000 so you see a scatter plot of the prices with a little bar chart below it that gives information about the volume on each day. I'm pretty sure that this should be a straightforward thing to do, but after two hours of Google and reading manuals, I ask you fine people.