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")). Thanks in advance for all the help, Monica _________________________________________________________________ _sync:082009 -------------- next part -------------- A non-text attachment was scrubbed... Name: robcor_training_pca.pdf Type: application/pdf Size: 733906 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090806/7cec32e6/attachment-0002.pdf>
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