Dear Jim and Petr, Thank you. The last code by Jim worked like magic. A great relief. Thank you very much. Best wishes Ogbos On Thu, Nov 21, 2019 at 10:59 AM Jim Lemon <drjimlemon at gmail.com> wrote:> > Hi Ogbos, > As Petr says, you can use twoord.plot for this: > > dta<-read.table(text="year month day hour Li CR x1 x2 > 04 12 31 10 8637 4992 0.310676228913214 49.7113438132607 > 04 12 31 11 8634 4183 0.275834035016405 25.4492290005748 > 04 12 31 12 8652 4160 0.484887198397259 24.7594531777172 > 04 12 31 13 8626 3411 0.182921517958247 2.2967535550946 > 04 12 31 15 8618 3904 0.09000900090009 17.0819483667808 > 04 12 31 16 8620 3428 0.113237130164629 2.80658785894585 > 04 12 31 17 8603 3041 -0.0842019685839552 -8.79964011696198 > 04 12 31 18 8579 2340 -0.362939519758427 -29.8228075875341 > 04 12 31 19 8588 3006 -0.258412938068 -9.8492989778322 > 04 12 31 20 8604 3280 -0.0725879039516855 -1.63196960987679 > 04 12 31 21 8568 3696 -0.490694230713394 10.8439757078949 > 04 12 31 22 8567 2307 -0.502308295345664 -30.8124859420688 > 04 12 31 23 8570 2726 -0.467466101448855 -18.2465698647939 > 05 01 01 00 8579 2879 -0.568878758318289 8.46755203918244 > 05 01 01 01 8581 1586 -0.545698639133843 -40.2467740416313 > 05 01 01 02 8562 1183 -0.765909771386082 -55.4299708015447 > 05 01 01 03 8602 1491 -0.302307387697159 -43.8259395309409 > 05 01 01 04 8576 1742 -0.603648937094958 -34.369407553923 > 05 01 01 05 8622 2001 -0.0705061958526974 -24.6114721672789 > 05 01 01 06 8613 2675 -0.174816732182705 0.781765093717623 > 05 01 01 07 8622 3293 -0.0705061958526974 24.0651784873316 > 05 01 01 08 8628 4333 -0.00096583829935895 63.2476217387209 > 05 01 01 09 8669 16 0.474226604981787 -99.3971931807479 > 05 01 01 10 8698 3671 0.810338333156256 38.3064895921635 > 05 01 01 11 8671 3856 0.497406724166233 45.2764434397664 > 05 01 01 12 8679 3411 0.590127200904018 28.5108787793162 > 05 01 01 13 8647 3428 0.219245293952879 29.1513610247716 > 05 01 01 14 8651 4596 0.265605532321772 73.156258830178 > 05 01 01 15 8638 3154 0.114934757622872 18.8282942450786 > 05 01 01 16 8635 2365 0.0801645788462025 -10.8976170292926 > 05 01 01 17 8628 2697 -0.00096583829935895 1.61062447018932 > 05 01 01 18 8653 3231 0.288785651506218 21.7293020627296 > 05 01 01 19 8657 3548 0.33514588987511 33.6724121691627 > 05 01 01 20 8650 2645 0.254015472729549 -0.348497692380145 > 05 01 01 21 8605 2153 -0.26753720892049 -18.8848073843835 > 05 01 01 22 8600 1759 -0.325487506881605 -33.7289253084676", > header=TRUE,stringsAsFactors=FALSE) > library(plotrix) > dta$year<-ifelse(dta$year < 50,dta$year+2000,dta$year+1900) > dta$date<-strptime(paste(paste(paste(dta$year,dta$month,dta$day,sep="-"), > paste(dta$hour,0,0,sep=":"),sep=" ")),"%Y-%m-%d %H:%M:%S") > xlim<-range(as.numeric(dta$date)) > xorigin<-as.POSIXct("1970-01-01 0:0:0","%Y-%m-%d %H:%M:%S") > xticks<-as.POSIXct(pretty(range(as.numeric(dta$date))),origin=xorigin) > twoord.plot(dta$date,dta$Li,dta$date,dta$CR,xlim=xlim,xaxt="n", > main="Lightning and GCR frequency", > xlab="Date",ylab="Lightning count/day",rylab="GCR count/day", > xtickpos=xticks,xticklab=format(xticks,"%Y-%m-%d %H")) > > Jim > > On Thu, Nov 21, 2019 at 7:49 PM Ogbos Okike <giftedlife2014 at gmail.com> wrote: > > > > Dear Members, > > I have some hourly data. Usin: > > dta$year <- with( dta, ifelse(year < 50, year + 2000, year + 1900)) > > dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year, month,day,hour,0,0))) > > I converted the hour to time format and stored in Year. > > The data consists of two different observations and I wish to plot > > same on one graph (two y-axis and common x-axis). > >