[R] clock24.plot
Jim Lemon
drjimlemon at gmail.com
Fri Apr 22 12:30:46 CEST 2016
Hi Ogbos,
Here is your sample data plotted in roughly the same way as the image.
You can get the hours to start at the bottom, but it will require more
code.
swe$hour<-as.numeric(sapply(strsplit(swe$time,":"),"[",1))
swe$FD<-sample(1:2,nrow(swe),TRUE)
library(plotrix)
clock24.plot(swe$count,swe$hour,rp.type="s",radial.lim=c(3000,4010),
show.grid.labels=0,point.col=swe$FD,mar=c(2,2,6,2))
legend(0,1600,c("FD1","FD2"),pch=1,col=1:2,xjust=0.5,yjust=0.5,
xpd=TRUE)
Jim
On Fri, Apr 22, 2016 at 3:01 PM, Ogbos Okike <giftedlife2014 at gmail.com> wrote:
> Dear Jim,
> I am forwarding the same mail from my phone to be sure you have it.
> Additionally, will my data require a daylight plot?
> Many thanks for your time.
> Ogbos
>
> ---------- Forwarded message ----------
> From: "Ogbos Okike" <giftedlife2014 at gmail.com>
> Date: Apr 22, 2016 5:42 AM
> Subject: Fwd: clock24.plot
> To: "Ogbos Okike" <giftedlife2014 at gmail.com>
> Cc:
>
>
> ---------- Forwarded message ----------
> From: Ogbos Okike <giftedlife2014 at gmail.com>
> Date: Fri, Apr 22, 2016 at 5:28 AM
> Subject: Re: clock24.plot
> To: Jim Lemon <drjimlemon at gmail.com>
>
>
> Dear Jim,
> Thank you for your time. I am working on comic ray data this time. I think
> that displaying the format of my data will make things much easier for me.
> Here is a part of my data:
> 2005/01/01 00:00 4009
> 2005/01/01 01:00 3969
> 2005/01/01 02:00 3946
> 2005/01/01 03:00 3975
> 2005/01/01 04:00 3960
> 2005/01/01 05:00 3974
> 2005/01/01 06:00 3971
> 2005/01/01 07:00 3970
> 2005/01/01 08:00 3962
> 2005/01/01 09:00 3992
> 2005/01/01 10:00 3955
> 2005/01/01 11:00 3963
> 2005/01/01 12:00 3965
> 2005/01/01 13:00 3947
> 2005/01/01 14:00 3959
> 2005/01/01 15:00 3978
> 2005/01/01 16:00 3967
> 2005/01/01 17:00 3978
> 2005/01/01 18:00 3988
> 2005/01/01 19:00 4043
> 2005/01/01 20:00 4026
> 2005/01/01 21:00 3996
> 2005/01/01 22:00 3967
> 2005/01/01 23:00 3969
> 2005/01/02 00:00 3976
> 2005/01/02 01:00 3969
> 2005/01/02 02:00 3955
> 2005/01/02 03:00 3984
> 2005/01/02 04:00 3971
> 2005/01/02 05:00 3960
> 2005/01/02 06:00 3951
> 2005/01/02 07:00 3948
> 2005/01/02 08:00 3954
> 2005/01/02 09:00 3948
> 2005/01/02 10:00 3960
> 2005/01/02 11:00 3964
> 2005/01/02 12:00 3962
> This run for 56 years.
> The type of plot I wish to generated is attached. If I have an idea of how
> to use my data and generate the kind of graph attached, I can then start
> playing with many stations as the different colours represent.
>
> Thank you so much for assisting.
> Ogbos
>
> On Fri, Apr 22, 2016 at 4:53 AM, Jim Lemon <drjimlemon at gmail.com> wrote:
>>
>> Hi Ogbos,
>> Here is an example that might get you started:
>>
>> lightning<-data.frame(year=rep(1901:2000,each=100),time=runif(10000,0,24))
>> lightning$hour<-floor(lightning$time)
>> clock24.plot(as.vector(table(lightning$hour)),0:23,rp.type="p",
>> show.grid.labels=0,main="24 hour distribution of lightning strikes",
>> radial.lim=c(360,460),mar=c(3,2,3,2))
>> segments(c(0,0,100),c(-130,-130,-130),c(100,0,100),c(-130,-128,-128))
>> mtext(c(360,460),side=1,at=c(0,100),line=1)
>>
>> As you say you have date/time values, you will have to extract the
>> time values from the date/times. If all you want is something like the
>> hours as in the above example, you can just do this:
>>
>> mydata$hours<-format(strptime(mydatetimes,<date time format>),"%H")
>> hour_freq<-as.vector(table(mydata$hours))
>>
>> I am assuming that you want some sort of frequency distribution during
>> the day. If I have misunderstood, please let me know.
>>
>> Jim
>>
>> On Fri, Apr 22, 2016 at 12:56 PM, Ogbos Okike <giftedlife2014 at gmail.com>
>> wrote:
>> > Dear Jim,
>> > I am trying to understand one of your codes on clock24.plot. I have not
>> > been
>> > quite successful. My data run for 24hours for many years. Most of the
>> > examples you put online were generated by rnorm function.
>> > Since I have two columns with date time and the actual data, can you
>> > give me
>> > an idea on how to go.
>> > Thanks for time.
>> > Ogbos
>
>
>
More information about the R-help
mailing list