Re: [R] help cannot put multiple chart Stacked Bar (from PerformanceAnalysis library) in a single plot
I am unfamiliar with the chart.StackedBar function, but since barplot works as expected I thought I'd check that you do know you can obtain stacked bar charts using barplot also? (beside = FALSE). On 10 November 2010 09:41, patrick nguyen wrote: > Hi > > > I'm having problems displaying multiple chart.StackedBar from > PerformanceAnalysis library on a single plot. I've tried using > par(mfrow=c(2,1)) but that doesn't work. > > If I do it with barplot(), it works fine and I see both plots on a single > plot. > > > plot(mfrow=c(2,1)) > > barplot(blahblah) > > barplot(blahblah) > > However if I try to use chart.StackedBar, the second entry appears to just > overwrite the window. > > > plot(mfrow=c(2,1)) > > chart.StackedBar(blahblah,date.format="%H:%M:%S",las=2, > >colorset=rainbow12equal) > > chart.StackedBar(blahblah,date.format="%H:%M:%S",las=2, > >colorset=rainbow12equal) > > Any suggestions are greatly appreciated! > > -patrick > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help cannot put multiple chart Stacked Bar (from PerformanceAnalysis library) in a single plot
Hi, try par(new=T) patrick nguyen writes: Hi I'm having problems displaying multiple chart.StackedBar from PerformanceAnalysis library on a single plot. I've tried using par(mfrow=c(2,1)) but that doesn't work. If I do it with barplot(), it works fine and I see both plots on a single plot. plot(mfrow=c(2,1)) barplot(blahblah) barplot(blahblah) However if I try to use chart.StackedBar, the second entry appears to just overwrite the window. plot(mfrow=c(2,1)) chart.StackedBar(blahblah,date.format="%H:%M:%S",las=2, colorset=rainbow12equal) chart.StackedBar(blahblah,date.format="%H:%M:%S",las=2, colorset=rainbow12equal) Any suggestions are greatly appreciated! -patrick __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help cannot put multiple chart Stacked Bar (from PerformanceAnalysis library) in a single plot
On Tue, Nov 9, 2010 at 12:41 PM, patrick nguyen wrote: > Hi > > > I'm having problems displaying multiple chart.StackedBar from > PerformanceAnalysis library on a single plot. I've tried using I am assuming you mean the PerformanceAnalytics package, at least that is what I will talk about. > par(mfrow=c(2,1)) but that doesn't work. > > If I do it with barplot(), it works fine and I see both plots on a single > plot. > >> plot(mfrow=c(2,1)) >> barplot(blahblah) >> barplot(blahblah) this works because barplot() just plots in the device opened by the call to par() (well, what would have been the call to par()) > > However if I try to use chart.StackedBar, the second entry appears to just > overwrite the window. > >> plot(mfrow=c(2,1)) >> chart.StackedBar(blahblah,date.format="%H:%M:%S",las=2, >>colorset=rainbow12equal) >> chart.StackedBar(blahblah,date.format="%H:%M:%S",las=2, >>colorset=rainbow12equal) The issue here is that chart.StackedBar calls par() itself, so it is overriding your settings. This will not be terribly easy to change. My guess is that you would have to alter the function itself. However, if you simple delete/comment its par call, there will likely be clipping issues with the fancy legend that it seems to add. If you provide data and exactly what it is you want (so for instance I know whether chart.StackedBar is being dispatched to the .xts or .matrix side) I might edit the function for you. Alternately you could just live with them separate and merge them in your paper or presentation or whatever. Just use the xlim and ylim arguments so they are on the same scale. Cheers, Josh > > Any suggestions are greatly appreciated! > > -patrick > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help cannot put multiple chart Stacked Bar (from PerformanceAnalysis library) in a single plot
Thx for the details Josh! You're right - I meant performance analytics. I'm about 4 weeks into R now so I'm a bit of a noob. I've downloaded the source to see what you're talking about. I'll play around with it. The data is pretty straight forward and has something like this: date,bucket,view,db "2010-10-31 04:44:44",10,11,12 "2010-10-31 04:44:45",13,14,15 ... ... contained in a csv file. I convert the class of data into xts prior to passing it into chart.StackedBar. -Patrick On Nov 9, 2010, at 1:56 PM, Joshua Wiley wrote: > On Tue, Nov 9, 2010 at 12:41 PM, patrick nguyen > wrote: >> Hi >> >> >> I'm having problems displaying multiple chart.StackedBar from >> PerformanceAnalysis library on a single plot. I've tried using > > I am assuming you mean the PerformanceAnalytics package, at least that > is what I will talk about. > >> par(mfrow=c(2,1)) but that doesn't work. >> >> If I do it with barplot(), it works fine and I see both plots on a single >> plot. >> >>> plot(mfrow=c(2,1)) >>> barplot(blahblah) >>> barplot(blahblah) > > this works because barplot() just plots in the device opened by the > call to par() (well, what would have been the call to par()) > >> >> However if I try to use chart.StackedBar, the second entry appears to just >> overwrite the window. >> >>> plot(mfrow=c(2,1)) >>> chart.StackedBar(blahblah,date.format="%H:%M:%S",las=2, >>> colorset=rainbow12equal) >>> chart.StackedBar(blahblah,date.format="%H:%M:%S",las=2, >>> colorset=rainbow12equal) > > The issue here is that chart.StackedBar calls par() itself, so it is > overriding your settings. This will not be terribly easy to change. > My guess is that you would have to alter the function itself. > However, if you simple delete/comment its par call, there will likely > be clipping issues with the fancy legend that it seems to add. > > If you provide data and exactly what it is you want (so for instance I > know whether chart.StackedBar is being dispatched to the .xts or > .matrix side) I might edit the function for you. Alternately you > could just live with them separate and merge them in your paper or > presentation or whatever. Just use the xlim and ylim arguments so > they are on the same scale. > > Cheers, > > Josh > >> >> Any suggestions are greatly appreciated! >> >> -patrick >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > > > -- > Joshua Wiley > Ph.D. Student, Health Psychology > University of California, Los Angeles > http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.