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.
Thank you very much for your kind response. Best wishes Ogbos Part of the two data are: 96 11 28 -5.0439243156971 96 11 30 -6.47673663925309 96 12 03 -6.82839470197342 96 12 05 -6.21642465505491 96 12 07 -6.25580747537018 96 12 10 -5.77540853474434 96 12 14 -3.98857218877879 96 12 16 -4.25191042337454 96 12 20 -3.20551034549018 96 12 24 -4.2702754047348 96 12 28 -6.03085851418479 96 12 31 -6.51403505358144 97 01 02 -6.32673280540791 97 01 08 -5.8537576420137 97 01 13 -5.54092007919419 97 01 23 -4.03617528404112 97 01 28 -6.21414660666954 97 01 30 -5.82248535055029 97 02 02 -4.52703090771556 97 02 04 -4.24731404905759 97 02 06 -5.22553031464346 97 02 10 -3.31737825603324 97 02 13 -1.48147648915881 97 02 16 -1.80195032791485 97 02 19 -2.16701154625054 97 02 21 -2.06571846213066 97 02 24 -3.39623775344558 97 03 02 -4.70829707054833 97 03 07 -3.73377684116639 97 03 11 -2.76476446486583 97 03 19 -2.30766786606313 97 03 21 -2.36150976836853 97 03 24 -1.84664525535518 97 04 01 -4.30618772775492 97 04 12 -4.51646004530582 97 04 19 -4.12507873323636 97 04 23 -3.46413598467606 97 04 25 -2.95371560706153 97 05 02 -4.04170720343953 97 05 13 -5.60975985858423 97 05 15 -5.52471869367602 97 05 23 -3.85761006637094 97 05 26 -3.47054347969788 97 05 29 -3.46506967197854 97 06 04 -0.307928317047413 97 06 08 -2.87534017937205 97 06 11 -3.00325467983916 97 06 14 -3.15331224991201 97 06 26 -3.14375164434693 97 07 02 -1.28362211606 and the second is: 98 05 02 -4.09334391050803 98 06 07 -0.161822520097844 98 06 19 -0.274151702680992 98 06 21 -0.285384620939307 98 06 25 -0.554974659138863 98 08 23 -2.22867947962777 98 08 27 -5.44129410150581 98 09 25 -4.46403021303242 98 11 09 -0.723468433013585 98 12 14 -0.824564697338419 99 01 16 -0.880729288629993 99 01 19 -0.566207577397178 99 01 21 -0.566207577397178 99 01 24 -4.99197737117322 99 02 13 -1.15031932682955 99 02 18 -5.733349976222 99 02 23 -0.869496370371678 99 03 06 -0.319083375714252 99 03 19 -1.35251185547922 99 03 24 -1.33004601896259 99 04 11 -0.229220029647733 99 04 16 -0.521275904363918 99 04 22 -1.2626485094127 99 05 07 -0.453878394814029 99 05 10 -1.35251185547922 99 05 24 -1.97032235968653 99 05 30 -0.330316293972566 99 06 06 -1.24018267289607 99 06 23 -0.0157945827397513 99 06 27 -2.86895582035172 99 07 03 -1.04922306250472 99 07 08 -0.375247967005826 99 07 24 -0.139356683581214 99 07 28 -1.50977271109562 99 07 31 -0.465111313072344 99 08 20 -4.35170103044927 99 08 22 -4.86841527033175 99 08 25 -4.03717931921646 99 09 01 -2.2511453161444 99 09 05 -3.22840920461779 99 09 07 -2.98128500293486 99 09 09 -3.28457379590937 99 09 16 -4.08211099224972 99 09 18 -4.00348056444151 99 09 21 -4.17197433831624 99 09 25 -3.11608002203464 99 09 29 -3.85745262708342 99 10 03 -3.77882219927522 and my code is: data <- read.table("AUTOFD2a", col.names = c("year", "month", "day","fd")) new.century <- data$year < 50 data$year <- ifelse(new.century, data$year + 2000, data$year + 1900) data$date <- as.Date(ISOdate(data$year, data$month, data$day)) x1 = data$date library(date) c1a<-rgb(1,0,0,8/9) hist(x1,breaks="years",freq=T,axes=F,col=c1a) data <- read.table("MANFD2a", col.names = c("year", "month", "day","fd")) new.century <- data$year < 50 data$year <- ifelse(new.century, data$year + 2000, data$year + 1900) data$date <- as.Date(ISOdate(data$year, data$month, data$day)) x2 = data$date c2a=rgb(0,0,1,8/9) hist(x2,breaks="years",freq=T,axes=F,add=T,col=c2a) axis.Date(1, at=seq(as.Date(min(x1)), as.Date(max(x1)), by="years")) axis(2) legend("topright", c("AUTO", "MANUAL"), col=c("red", "blue"), lwd=10) [[alternative HTML version deleted]] ______________________________________________ R-help@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.