Hi Jim,
 
Thanks for your answer. It does it but not quite as i would like it ;-) I need 
the colors to be blended as the colorRampPalette does it going from one color 
to the next in the list. Your legend will have 5 discreet colors and accept a 
vector of colors as the image.plot command does. If i can make the rainbow have 
my colors would be great. I will look more into that.
 
Thanks again, i really appreciate your suggestion,
 
Monica

----------------------------------------
> Date: Fri, 7 Aug 2009 21:11:46 +1000
> From: j...@bitwrit.com.au
> To: pisican...@hotmail.com
> CC: r-h...@stat.math.ethz.ch
> Subject: Re: [R] adding color bar to a graph
>
> Monica Pisica wrote:
>> Hi everybody,
>>
>> I am wondering how i can add a "stretch" color bar / legend to a graph that 
>> uses colorBrewer to define the colors in it. I will try to explain my graph, 
>> but i also uploaded it at: 
>> ftp://ftpext.usgs.gov/pub/er/fl/st.petersburg/Monica_pal/
>>
>> The file is: robcor_training_pca.pdf - i will also attach this file in case 
>> some people accept attachments.
>>
>> So i took apart the cor.plot function from mvoutlier and i used instead of 
>> the scatter plot function the smooth scatter density plot from geneplotter, 
>> generating my own function called cordens.plot. Now i would like to add a 
>> colorbar on the right side of the graph with red as my highest density and 
>> purple as the lowest density and right next to the colors labels "min" for 
>> purple and "max" for red (i don't want actual numbers, although i suppose i 
>> can deal with that as well if need be).
>>
>> I've tried image.plot function but i cannot set correctly the colors in the 
>> bar since i am not using an "orthodox" rainbow set. Originally my colors in 
>> the graph are set with colorRampPalette(c("darkviolet", "deepskyblue4", 
>> "green", "yellow", "red")).
>>
>>
> Hi Monica,
> I think color.legend in the plotrix package will do what you want.
>
> color.legend(200,0,220,100,legend=c("min","max"),
> rect.col=c("darkviolet","deepskyblue4","green","yellow","red"))
>
> and you will have to add some space on the right side
>
> par(mar=c(5,4,4,4))
>
> Jim
>
_________________________________________________________________


n-US:SI_PH_software:082009
______________________________________________
R-help@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.

Reply via email to