Re: [R] Split charts with ggplot2, tidyquant

2018-01-21 Thread Eric Berger
Hi Charlie and Bert, Thank you both for the suggestions and pointers. I will look into them. FYI I repeatedly refer to tidyquant because that package refers to itself as "tidyquant: Tidy Quantitative Financial Analysis" and I am hoping to get the attention of someone who is involved in the

Re: [R] Split charts with ggplot2, tidyquant

2018-01-21 Thread Charlie Redmon
Thanks for the reminder about lattice! I did some searching and there's a good example of manipulating the size of subplots using the `position` argument (see pp. 202-203 in the Trellis Users Guide: http://ml.stat.purdue.edu/stat695t/writings/Trellis.User.pdf). This is not within the paneling

Re: [R] Split charts with ggplot2, tidyquant

2018-01-20 Thread Bert Gunter
That (the need for base graphics) is false. It certainly **can** be done in base graphics -- see ?layout for a perhaps more straightforward way to do it along the lines you suggest. However both lattice and ggplot are based on grid graphics, which has a similar but slightly more flexible

Re: [R] Split charts with ggplot2, tidyquant

2018-01-20 Thread Charlie Redmon
For this kind of control you will probably need to move to base graphics and utilize the `fig` argument in par(), in which case you would want to run the plot() command twice: once with your first outcome and once with your second, changing the par() settings before each one to control the

Re: [R] Split charts with ggplot2, tidyquant

2018-01-19 Thread Eric Berger
Hi Charlie, Thanks. This is helpful. As mentioned in my original question, I want to be able to plot a few such charts on the same page, say a 2 x 2 grid with such a chart for each of 4 different stocks. Using your solution I accomplished this by making a list pLst of your ggplots and then calling

Re: [R] Split charts with ggplot2, tidyquant

2018-01-19 Thread Charlie Redmon
So the general strategy for getting these into separate panels in ggplot is to have a single variable that will be your response and a factor variable that indexes which original variable it came from. This can be accomplished in many ways, but the way I use is with the melt() function in the

Re: [R] Split charts with ggplot2, tidyquant

2018-01-18 Thread Joshua Ulrich
If you don't want to wait for a ggplot2 solution, here are two alternatives you can use right now: chartSeries(SPYxts) # or (with xts > 0.10 plot(SPYxts$SPY.Close) addSeries(SPYxts$SPY.Volume, type = "h") You might also try autoplot.zoo(), though I've never used it. On Thu, Jan 18, 2018 at

Re: [R] Split charts with ggplot2, tidyquant

2018-01-18 Thread Eric Berger
Hi Charlie, I am comfortable to put the data in any way that works best. Here are two possibilities: an xts and a data frame. library(quantmod) quantmod::getSymbols("SPY") # creates xts variable SPY SPYxts <- SPY[,c("SPY.Close","SPY.Volume")] SPYdf <-

Re: [R] Split charts with ggplot2, tidyquant

2018-01-18 Thread Charlie Redmon
Could you provide some information on your data structure (e.g., are the two time series in separate columns in the data)? The solution is fairly straightforward once you have the data in the right structure. And I do not think tidyquant is necessary for what you want. Best, Charlie --

[R] Split charts with ggplot2, tidyquant

2018-01-17 Thread Eric Berger
A very common chart in the financial markets is a split chart with two time series shown in two vertically stacked sub-charts. A classic case would be the top panel showing the time series of historical prices of some stock, and the bottom panel showing the volume traded per day immediately below