[R] Boxplot colors

Richard M. Heiberger rmh at temple.edu
Thu May 22 16:41:25 CEST 2014


## Shane,

## This uses your color_list.   Your other variables weren't included
in the email
## so I invented some data.

## I recommend bwplot() using panel=panel.bwplot.superpose

## and I also show how to use boxplot()


## install.packages("HH") ## if necessary.
library(HH)
## install.packages("reshape2") ## if necessary.
library(reshape2)

## you didn't include data, so I am making up some data
pH <- data.frame(matrix(rnorm(200), 10, 20))

bwplot(value ~ variable, data=melt(pH), col=unlist(colors_list),
       panel=panel.bwplot.superpose, groups=variable)

boxplot(value ~ variable, data=melt(pH), col=unlist(colors_list))

## Rich

On Thu, May 22, 2014 at 5:50 AM, Shane Carey <careyshan at gmail.com> wrote:
> Hi
>
> Im producing boxplots based on factors and rearranging them by median (This
> is for a Geochemistry element). Im giving each boxplot a unique color based
> on its level (factor) name.
>
> Im trying to produce a look up list to produce these colors as the order of
> the boxplots will change from element to element.
>
> Here is by color lool up and boxplot code:
>
> colors_list<-list("Dalradian Appin Group quartzite"="#FFFF00","Sperrins
> Dalradian (position uncertain)"="#D7D79E",
>                   "Namurian sandstone, shale"="#C7D79E","Lr-Mid Ordovocian
> acid volcanics"="#FFD37F",
>                   "Tertiary granite, felsite"="#FF5500","Caledonian
> appinite suite"="#946379",
>                   "Dalradian Argyll Gp quartzite"="#FFFF00","Slishwood
> Division" ="#FFEDCC",
>                   "Dalradian S Highland Gp volcanics"="#00E6A9","LEITRIM
> GP; Visean mudstone, sandstone"="#E6CCCC",
>                   "Dalradian Argyll Group"="#FFD9C7","Metadolerite or
> amphibolite"="#4C7300",
>                   "Caledonian granite"="#FF7F7F","Dalradian Appin
> Group"="#9EAAD7",
>                   "Lr-Mid Ordovician basic volcanics"="#448970","Ordovician
> Granite"="#E60000",
>                   "Tertiary basic intrusion"="#8400A8","Dalradian Argyll Gp
> volcanics"="#00E6A9",
>                   "VISEAN \"\"basal clastics\"\""="#73A6A6","Carboniferous
> volcs & minor intrus"="#AAFF00",
>                   "Metagabbro, metadiorite (Tyrone Plu"="#00A885","TYRONE
> GP; Visean mudstone, sandstone"="#CC9999",
>                   "Late Visean-Westphalian 'ORS'"="#F5A27A","Dalradian S
> Highland Group"="#FFD9C7",
>                   "Mid Devonian ORS"="#FFD37F","Mid-Up Ordovician
> slate"="#C2753D",
>                   "Interbasaltic formation laterite, b"="#FFFF00","Visean
> shelf limestone, shale"="#FF00C5",
>                   "Tertiary rhyolite (volc&intru)"="#FFEABE","COURCEYAN
> \"\"basal clastics\"\""="#4D8099",
>                   "Up Dev-Lr Carb ORS"="#CDAA66","Tyrone CI
> (Corvanaghan=?Slishwood"="#C9FFC9",
>                   "Visean basinal limestone \"\"Calp\"\""="#CFD6EB","Mid-Up
> Ordovician g'wacke, sndst, shale"="#C29ED7",
>                   "Up Silurian - Lr Devonian ORS"="#CD8966","Westphalian
> shale, sandstone"="#B2B2B2",
>                   "Upper Basalt Formation"="#FAC2E0","Causeway Tholeiite
> Mbr"="#C29ED7",
>                   "Courceyan limestone"="#73B2FF","Tertiary minor
> volcanics"="#E600A9",
>                   "Silurian sandstone, g'wacke, shale"="#ADE6D1","Up
> Cretaceous limestone"="#73FFDF",
>                   "Lower Basalt Formation"="#E0A8C7","Ballycastle
> succession"="#CCB3B3",
>                   "Navan Group"="#408CBF","Devonian basic volcs, minor
> intrus"="#A5F57A",
>                   "Up. Ord-Sil \"\"Moffat shale\"\"
> etc."="#FFFFDB","Oligocene clay, sand"="#704489",
>                   "Lr Jurassic mudstone"="#704489","Lr Jurassic
> mudstone"="#267300",
>                   "Mid-Up Ordovician acid volcanics"="#448970","Armagh
> Gp"="#8073B3",
>                   "Rathkenny Formation"="#704489","Triassic
> sandstone"="#F7DB5E",
>                   "Waulsortian Limestones"="#B2B2B2","Permian
> sandstone"="#F5CA7A",
>                   "Mid-Up Ordovician basic volcanics"="#448970")
>
>
> boxplot(na.omit(C_pH$DATA.pH)~bymedian,axes=FALSE,horizontal=TRUE,col=unlist(colors_list),outwex=one,whisklty
> = "solid",whisklwd=lwth,outcol= "black", outpch=dtsym,  outcex=dtsize)
>
> However it is not reading the colors based on the color_list given here.
> Anyone know how to solve this?
>
> Thanks for your help
>
> --
> Shane
>
>         [[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