[R] Adding overlap legend to a histogram

Ogbos Okike g||ted|||e2014 @end|ng |rom gm@||@com
Fri May 8 08:06:20 CEST 2020


Dear Jim,
Thank you for looking into this.
Sorry, there was actually no overlap in the small part of the data I
reported. My error of omission.

So when I run my full data with the adjustment you made, I got some thing
that was far from what I was expecting. That tell me that I need to send
the complete data to enable you correctly adjust the code, especially in
the light of the missing/present overlap.
I have used deput function to attach the two files. Please use any symbol
to depict the color/mark/legend of the overlap dates (just to enable the
reader visualize what is going on). I am actually trying to display event
frequency/occurrence per year.

Thank you and warmest regards
Ogbos

On Fri, May 8, 2020 at 1:13 AM Jim Lemon <drjimlemon using gmail.com> wrote:

> Hi Ogbos,
> I don't think that your example allows us to work out what you are
> trying to do. For one thing, "x1" and "x2" do not overlap. Also, you
> are plotting the frequencies of dates of observations, which may not
> be what you want.
> The following code will correctly display your example:
>
> hist(x1,breaks="years",freq=T,axes=F,xlim=c(9400,11100),col=c1a)
> hist(x2,breaks="years",freq=T,axes=F,add=T,col=c2a)
>  axis.Date(1, at=seq(as.Date(min(x1)), as.Date(max(x2)), by="years"))
>  axis(2)
> legend("topleft", c("AUTO", "MANUAL"), fill=c("red", "blue"))
>
> What it is displaying is the frequency of observations in your two
> vectors by calendar year. If this is what you want, and you can
> explain how you would like "overlap" to be displayed, we can probably
> provide better help.
>
> Jim
>
>
> On Fri, May 8, 2020 at 7:01 AM Ogbos Okike <giftedlife2014 using gmail.com>
> wrote:
> >
> > Dear Experts,
> > Greetings.
> >
> > I am trying to display two datasets in a histogram. I have been able to
> > plot the graph and added the legend for the two colors. I am, however,
> > having difficulties adding a legend to represent the regions of overlap
> > (the third legend).  Below are my data and code.
>


More information about the R-help mailing list