[R] Struggling trying to plot points on boxplot
Thomas Adams
tea3rd at gmail.com
Thu Jun 2 20:07:14 CEST 2016
Bill,
Thank you!! With some tweaking, this approach was exactly what I needed.
Previously, I had been using bxp and had my code for it, but my data was
structured completely differently from what I have now. I figured something
like groupedX <- with(d, split(x, group)) existed, but how to find it??
This was the key for me and it's so powerful!
Thanks to all for the suggestions!
Tom
On Thu, Jun 2, 2016 at 10:52 AM, William Dunlap <wdunlap at tibco.com> wrote:
> Does using zz<-bxp(boxplot(data,plot=FALSE)) do what you want? E.g.,
>
> d <- transform(data.frame(t=1:15), x = sin(t)+log2(t), group =
> paste("Group", t%/%4))
> groupedX <- with(d, split(x, group))
> zz <- bxp(boxplot(groupedX, plot=FALSE)) # bxp returns the x positions of
> the boxes
> points(col="blue", pch=15, zz, vapply(splitX, FUN=mean, FUN.VALUE=0))
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Thu, Jun 2, 2016 at 8:36 AM, Thomas Adams <tea3rd at gmail.com> wrote:
>
>> Hello all:
>>
>> I've been beating my head on this for over a day and I have done a lot of
>> Google'ing with no luck.
>>
>> I have generated a 'time-series' of boxplots (227), covering more than a
>> 30-day period at 6-hour intervals, which summarize an ensemble forecast.
>> What I want to do is over-plot the observed values over a portion of the
>> forecast period to serve as a basis of comparison; so, there would be a
>> boxplot and a single point value plotted at each 6-hour interval.
>>
>> The boxplots are generated:
>>
>> zz<-boxplot(ens$value ~ ens$valid_time,xlab="Date/Time
>> (UTC)",ylab="Flow(cfs)",boxfill="cyan")
>>
>> which works fine, but the observed points will not display using:
>>
>> points(zz, obs$value,lty=3,lwd=1,col="red",pch=19)
>>
>> I've tried many variations of the latter, where either nothing happens and
>> no error is returned or I have also gotten that x and y have different
>> lengths. I suspect I am using the wrong 'x' type. I have observation
>> values
>> beginning with the first in the series of boxplots, which then end, with
>> the most recent ensemble forecast. So, I always expect the number of
>> observed values to be less than the number of boxplots. I have done this
>> previously, years ago, but can not find my notes and can not reconstruct
>> what I did.
>>
>> Help is appreciated.
>>
>> Regards,
>> Tom
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>>
>
>
--
Thomas E Adams, III
2330 Jack Warner PKWY, #334
Tuscaloosa, AL 35401
1 (513) 739-9512 (cell)
[[alternative HTML version deleted]]
More information about the R-help
mailing list