Created
November 30, 2012 21:58
-
-
Save mages/4178986 to your computer and use it in GitHub Desktop.
Setting lattice colour and legend options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(MASS) | |
library(lattice) | |
## Plot the claims frequency against age group by engine size and district | |
barchart(Claims/Holders ~ Age | Group, groups=District, | |
data=Insurance, origin=0, auto.key=TRUE) | |
barchart(Claims/Holders ~ Age | Group, groups=District, | |
data=Insurance,main="Claims frequency", | |
auto.key=list(space="top", columns=4, | |
title="District", cex.title=1)) | |
xyplot(Claims/Holders ~ Age | Group, groups=District, | |
data=Insurance, t="l", main="Claims frequency", | |
auto.key=list(space="top", columns=4, | |
title="District", cex.title=1, | |
lines=TRUE, points=FALSE)) | |
show.settings() | |
library(RColorBrewer) | |
display.brewer.all() | |
myColours <- brewer.pal(6,"Blues") | |
## Create your own list with | |
my.settings <- list( | |
superpose.polygon=list(col=myColours[2:5], border="transparent"), | |
strip.background=list(col=myColours[6]), | |
strip.border=list(col="black") | |
) | |
barchart(Claims/Holders*100 ~ Age | Group, groups=District, | |
data=Insurance, origin=0, | |
auto.key=list(space="top", columns=4, | |
points=FALSE, rectangles=TRUE, | |
title="District", cex.title=1), | |
main="Motor insurance claims frequency", | |
xlab="Age", ylab="Claims frequency %", | |
scales=list(alternating=1), | |
par.settings = my.settings, | |
par.strip.text=list(col="white", font=2), | |
panel=function(x,y,...){ | |
panel.grid(h=-1, v=0); | |
panel.barchart(x,y,...) | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment