Dear All, Thank you for your advice.
I have looked at the plotrix package and with what I gathered, I tinkered with the code below and obtain the attached graph: oolt<-read.table("QUERY2",col.names=c("Lat","Lon")) latlim<-c(20,45) lonlim<-c(-180,180) latbreaks<-seq(latlim[1],latlim[2],by=5) lonbreaks<-seq(lonlim[1],lonlim[2],by=10) mids<-function(x) { lenx<-length(x) return((x[1:(lenx-1)]+x[2:lenx])/2) } lonmids<-mids(lonbreaks) latmids<-mids(latbreaks) oolt$loncuts<-cut(oolt$Lon,lonbreaks) oolt$latcuts<-cut(oolt$Lat,latbreaks) counts<-table(oolt$latcuts,oolt$loncuts) png("test.png") library(plotrix) countcol<-color.scale(counts,extremes=c("blue","red")) library(maps) map("world",xlim=c(-180,180),ylim=c(20,45)) w = map("world") for(lon in 1:length(lonmids)) { for(lat in 1:length(latmids)) { if(counts[lat,lon] > 0) draw.circle(lonmids[lon],latmids[lat],radius=sqrt(counts[lat,lon]), border=countcol[lat,lon],col=countcol[lat,lon]) } } box() axis(1) axis(2) x<-seq(-180,180,30) y<-seq(-90,90,30) nx = 12 ny = 6 grid(nx,ny,col = "red",lty="dotted",lwd=par("lwd"),equilogs=TRUE) testcol<-color.gradient(c(10,30),0,c(30,10),nslices=5) color.legend(-180,-130,100,-150,countcol,testcol,gradient="x") I now have the horizontal color legend. But I have two major problems still. (1) The black line on top of the color bar is meaningless and I want it go. (2) I want the numerical values plotted to appear on the color bar (see the color.legend.png attached please) such that it can be used to interpret the map. I would be most grateful for any further assistance. Very best wishes Ogbos On Tue, Dec 11, 2018 at 11:14 AM Jim Lemon <drjimle...@gmail.com> wrote: > > Hi Ogbos, > I have been off the air for a couple of days. Look at the color.legend > function in the plotrix package. > > Jim > On Tue, Dec 11, 2018 at 12:39 PM Ogbos Okike <giftedlife2...@gmail.com> wrote: > > > > Dear Jim, > > I am still having trouble with the colour code. I await your help when > > you are less busy. > > > > Thank you. > > Best > > Ogbos > > On Mon, Dec 10, 2018 at 6:25 AM Ogbos Okike <giftedlife2...@gmail.com> > > wrote: > > > > > > Dear Jim, > > > > > > I used a bit of my data in my attempt to follow the code. > > > > > > I got the attached plot after some tweaks. > > > > > > I would like to add horizontal color bar legend that could be used to > > > explain the number of lightning counts at different points on the > > > latitude band as plotted. > > > > > > Thank you > > > Warm regards > > > Ogbos > > > > > > On Sun, Dec 9, 2018 at 9:46 PM Jim Lemon <drjimle...@gmail.com> wrote: > > > > > > > > Hi Ogbos, > > > > Here is a slight modification of a method I use to display trip > > > > density on a map: > > > > > > > > oolt<-read.table(text="Lat Lon > > > > 30.1426 104.7854 > > > > 30.5622 105.0837 > > > > 30.0966 104.6213 > > > > 29.9795 104.8430 > > > > 39.2802 147.7295 > > > > 30.2469 104.6543 > > > > 26.4428 157.7293 > > > > 29.4782 104.5590 > > > > 32.3839 105.3293 > > > > 26.4746 157.8411 > > > > 25.1014 159.6959 > > > > 25.1242 159.6558 > > > > 30.1607 104.9100 > > > > 31.4900 -71.8919 > > > > 43.3655 -74.9994 > > > > 30.0811 104.8462 > > > > 29.0912 -85.5138 > > > > 26.6204 -80.9342 > > > > 31.5462 -71.9638 > > > > 26.8619 97.3844 > > > > 30.2534 104.6134 > > > > 29.9311 -85.3434 > > > > 26.1524 159.6806 > > > > 26.5112 158.0233 > > > > 26.5441 158.0565 > > > > 27.8901 -105.8554 > > > > 30.3175 104.7135 > > > > 26.4822 157.6127 > > > > 30.1887 104.5986 > > > > 29.5058 104.5661 > > > > 26.4010 157.5749 > > > > 30.2281 104.7585 > > > > 31.4556 110.5619 > > > > 30.1700 104.5861 > > > > 26.3911 157.4776 > > > > 30.6493 104.9949 > > > > 30.2209 104.6629 > > > > 26.0488 97.3608 > > > > 30.2142 104.8023 > > > > 30.1806 104.8158 > > > > 25.2107 160.1690 > > > > 30.6708 104.9385 > > > > 30.4152 104.7002 > > > > 30.2446 104.7804 > > > > 29.5760 -85.1535 > > > > 26.4484 92.4312 > > > > 26.3914 157.4189 > > > > 26.3986 157.4421 > > > > 30.4903 -88.2271 > > > > 30.6727 104.8768 > > > > 30.2518 104.6466 > > > > 41.6979 -78.4136 > > > > 33.7575 72.1089 > > > > 26.8333 -80.9485 > > > > 25.3103 124.0978 > > > > 30.1742 104.7554 > > > > 30.6345 104.9739 > > > > 30.2075 104.7960 > > > > 30.2226 104.7517 > > > > 30.5948 105.0532", > > > > header=TRUE) > > > > latlim<-c(20,45) > > > > lonlim<-c(-90,160) > > > > latbreaks<-seq(latlim[1],latlim[2],by=5) > > > > lonbreaks<-seq(lonlim[1],lonlim[2],by=10) > > > > > > > > mids<-function(x) { > > > > lenx<-length(x) > > > > return((x[1:(lenx-1)]+x[2:lenx])/2) > > > > } > > > > lonmids<-mids(lonbreaks) > > > > latmids<-mids(latbreaks) > > > > oolt$loncuts<-cut(oolt$Lon,lonbreaks) > > > > oolt$latcuts<-cut(oolt$Lat,latbreaks) > > > > counts<-table(oolt$latcuts,oolt$loncuts) > > > > library(plotrix) > > > > countcol<-color.scale(counts,extremes=c("blue","red")) > > > > map("world",xlim=c(-90,160),ylim=c(20,45)) > > > > for(lon in 1:length(lonmids)) { > > > > for(lat in 1:length(latmids)) { > > > > if(counts[lat,lon] > 0) > > > > draw.circle(lonmids[lon],latmids[lat],radius=sqrt(counts[lat,lon]), > > > > border=countcol[lat,lon],col=countcol[lat,lon]) > > > > } > > > > } > > > > > > > > If you have very large counts in some places you may need to adjust > > > > the radius of the circles. > > > > > > > > Jim > > > > On Mon, Dec 10, 2018 at 2:50 AM Ogbos Okike <giftedlife2...@gmail.com> > > > > wrote: > > > > > > > > > > Dear Contributors, > > > > > > > > > > I have a data of the form: > > > > > Lat Lon > > > > > 30.1426 104.7854 > > > > > 30.5622 105.0837 > > > > > 30.0966 104.6213 > > > > > 29.9795 104.8430 > > > > > 39.2802 147.7295 > > > > > 30.2469 104.6543 > > > > > 26.4428 157.7293 > > > > > 29.4782 104.5590 > > > > > 32.3839 105.3293 > > > > > 26.4746 157.8411 > > > > > 25.1014 159.6959 > > > > > 25.1242 159.6558 > > > > > 30.1607 104.9100 > > > > > 31.4900 -71.8919 > > > > > 43.3655 -74.9994 > > > > > 30.0811 104.8462 > > > > > 29.0912 -85.5138 > > > > > 26.6204 -80.9342 > > > > > 31.5462 -71.9638 > > > > > 26.8619 97.3844 > > > > > 30.2534 104.6134 > > > > > 29.9311 -85.3434 > > > > > 26.1524 159.6806 > > > > > 26.5112 158.0233 > > > > > 26.5441 158.0565 > > > > > 27.8901 -105.8554 > > > > > 30.3175 104.7135 > > > > > 26.4822 157.6127 > > > > > 30.1887 104.5986 > > > > > 29.5058 104.5661 > > > > > 26.4010 157.5749 > > > > > 30.2281 104.7585 > > > > > 31.4556 110.5619 > > > > > 30.1700 104.5861 > > > > > 26.3911 157.4776 > > > > > 30.6493 104.9949 > > > > > 30.2209 104.6629 > > > > > 26.0488 97.3608 > > > > > 30.2142 104.8023 > > > > > 30.1806 104.8158 > > > > > 25.2107 160.1690 > > > > > 30.6708 104.9385 > > > > > 30.4152 104.7002 > > > > > 30.2446 104.7804 > > > > > 29.5760 -85.1535 > > > > > 26.4484 92.4312 > > > > > 26.3914 157.4189 > > > > > 26.3986 157.4421 > > > > > 30.4903 -88.2271 > > > > > 30.6727 104.8768 > > > > > 30.2518 104.6466 > > > > > 41.6979 -78.4136 > > > > > 33.7575 72.1089 > > > > > 26.8333 -80.9485 > > > > > 25.3103 124.0978 > > > > > 30.1742 104.7554 > > > > > 30.6345 104.9739 > > > > > 30.2075 104.7960 > > > > > 30.2226 104.7517 > > > > > 30.5948 105.0532. > > > > > The record is for lightning flashes in the continental U.S. and > > > > > surrounding waters within the latitudinal band between > > > > > 258 and 458N. > > > > > > > > > > I want to display the result in x-y co-ordinate plot. However, the > > > > > data is very large such that when plotted, everything just appeared > > > > > blurred. > > > > > > > > > > > > > > > Is there a way of using color codes to indicate the regions of higher > > > > > or lower flash densities? > > > > > > > > > > I can attach the plot I generated but I am not sure if the moderator > > > > > will allow it to go with this. > > > > > > > > > > I will send it in a separate email if required. > > > > > > > > > > Thank you so much for sparing your time. > > > > > > > > > > Best > > > > > Ogbos > > > > > > > > > > ______________________________________________ > > > > > 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.
______________________________________________ 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.