[R] help cannot put multiple chart Stacked Bar (from PerformanceAnalysis library) in a single plot
Patrick Nguyen
patrickqnguyen at yahoo.com
Thu Nov 11 10:50:31 CET 2010
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 <jwiley.psych at gmail.com> wrote:
> On Tue, Nov 9, 2010 at 12:41 PM, patrick nguyen
> <patrickqnguyen at yahoo.com> 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 at 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/
More information about the R-help
mailing list