[R] outlining symbol in legend with blackline

Yasir Kaheil kaheil at gmail.com
Wed Jul 9 20:40:00 CEST 2008


yes use plotting chars 22, 21
replace your legend statement with:

legend(x="topright", legend=c("2006 mean", "2007 mean", "2008 mean", 
"1964-2005 mean \n max and min flows "), pch=c(22, 22, 22, 21), 
col=c(1,1,1,1), pt.bg=c(grey.colors(3, gamma=4),"black"), cex=1.5) 
box(which="plot", lty="solid") 

thnaks
y


stephen sefick wrote:
> 
> # I would like to outline the squares in the legend with a black line. 
> Does
> anyone know how to do this?
> 
> x.t <- structure(c(5987.387, 4354.516, 3685.789, 6478.592, 5924.315,
> NA, 8386, 5559.468, NA, 4651.273, 3967.5, NA, 4339.167, 5053.56,
> NA, 4631.978, 4808.694, NA, 5217.306, 4017.632, NA, 5846.903,
> 3969.883, NA, 3867.825, 3910.236, NA, 3886.434, 3782.094, NA,
> 3959.668, 3961.286, NA, 3848.853, 3711.262, NA), .Dim = c(3L,
> 12L), .Dimnames = list(c("Year.2006", "Year.2007", "Year.2008"
> ), c("January", "February", "March", "April", "May", "June",
> "July", "August", "September", "October", "November", "December"
> )))
> 
> library(IDPmisc)
> barplot(x.t, beside=T, ylim=c(0, 40000), yaxt="n", ylab="Discharge(cfs)",
> col=grey.colors(3, gamma=4))
> axis(side=2, at=c(0,4000 ,7000, 10000,15000,
> 20000,25000,30000,35000,40000))
> legend(x="topright", legend=c("2006 mean", "2007 mean", "2008 mean",
> "1964-2005 mean \n max and min flows "), pch=c(15, 15, 15, 19),
> col=c(grey.colors(3, gamma=4),"black"), cex=1.5)
> box(which="plot", lty="solid")
> 
> points(2.5, 8313, pch=19, lwd=4)
> points(6, 9665, pch=19, lwd=4)
> points(10, 10675, pch=19, lwd=4)
> points(14, 10303, pch=19, lwd=4)
> points(18, 7926, pch=19, lwd=4)
> points(22, 7278, pch=19, lwd=4)
> points(26, 6472, pch=19, lwd=4)
> points(30, 6719, pch=19, lwd=4)
> points(34, 6123, pch=19, lwd=4)
> points(38, 6280, pch=19, lwd=4)
> points(42, 6334, pch=19, lwd=4)
> points(46, 7707, pch=19, lwd=4)
> 
> #max thurmond flow bar
> Arrows(2.5, 8229, 2.5, 25580, size=0, sh.lwd=4)
> Arrows(6, 9555, 6, 28571, size=0, sh.lwd=4)
> Arrows(10, 10547, 10, 23153, size=0, sh.lwd=4)
> Arrows(14, 10182, 14, 37591, size=0, sh.lwd=4)
> Arrows(18, 7847, 18, 22521, size=0, sh.lwd=4)
> Arrows(22, 7206, 22, 18384, size=0, sh.lwd=4)
> Arrows(26, 6472, 26, 15489, size=0, sh.lwd=4)
> Arrows(30, 6719, 30, 16659, size=0, sh.lwd=4)
> Arrows(34, 6123, 34, 11841, size=0, sh.lwd=4)
> Arrows(38, 6280, 38, 14282, size=0, sh.lwd=4)
> Arrows(42, 6334, 42, 17364, size=0, sh.lwd=4)
> Arrows(46, 7707, 46, 25877, size=0, sh.lwd=4)
> 
> #min thurmond flow bar
> Arrows(2.5, 8229, 2.5, 3602, size=0, sh.lwd=4)
> Arrows(6, 9555, 6, 3377, size=0, sh.lwd=4)
> Arrows(10, 10547, 10, 3490, size=0, sh.lwd=4)
> Arrows(14, 10182, 14, 3278, size=0, sh.lwd=4)
> Arrows(18, 7847, 18, 3579, size=0, sh.lwd=4)
> Arrows(22, 7206, 22, 3605, size=0, sh.lwd=4)
> Arrows(26, 6472, 26, 3579, size=0, sh.lwd=4)
> Arrows(30, 6719, 30, 3734, size=0, sh.lwd=4)
> Arrows(34, 6123, 34, 3694, size=0, sh.lwd=4)
> Arrows(38, 6280, 38, 3657, size=0, sh.lwd=4)
> Arrows(42, 6334, 42, 3287, size=0, sh.lwd=4)
> Arrows(46, 7707, 46, 3345, size=0, sh.lwd=4)
> 
> 
> -- 
> Let's not spend our time and resources thinking about things that are so
> little or so large that all they really do for us is puff us up and make
> us
> feel like gods. We are mammals, and have not exhausted the annoying little
> problems of being mammals.
> 
> -K. Mullis
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
> 
> 


-----
Yasir H. Kaheil
Catchment Research Facility
The University of Western Ontario 

-- 
View this message in context: http://www.nabble.com/outlining-symbol-in-legend-with-blackline-tp18367274p18368074.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list