[R] Simple color strip

baptiste auguie baptiste.auguie at googlemail.com
Wed Oct 19 22:03:57 CEST 2011


Hi,

Perhaps the easiest way is with grid.raster,

library(grid)
pdf("colorstrip.pdf", height=1, width=10)
grid.raster( t(myCols), width=unit(1,"npc"), height=unit(1,"npc"),
interpolate=FALSE)
dev.off()

HTH,

baptiste

On 20 October 2011 03:32, Brian Smith <bsmith030465 at gmail.com> wrote:
> Hi,
>
> I was trying to get an image/pdf of a sequence of colors in the order given.
> For example:
>
> myCols <- c('#0000BF','#0000BF','#0000FF','#0000FF','#0000BF','#0000FF')
>
>
> I'd like to make a strip of colors as they appear in the order above and
> save it as a pdf file. Is there a function in the base package (or some
> other package) to do this?
>
> thanks!
>
>        [[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.
>



More information about the R-help mailing list