[R] Canadian politcal party colours in ggplot2

Ista Zahn istazahn at gmail.com
Wed Apr 3 15:43:25 CEST 2013


Hi John,

How about this:

library(XML)

party.info <- readHTMLTable("http://en.wikipedia.org/wiki/Wikipedia:WikiProject_Political_parties_and_politicians_in_Canada/list_of_parties")
fed.party.info <- party.info[[3]]
fed.party.colors <- fed.party.info[, 2]
names(fed.party.colors) <- gsub("^.*\\|", "", fed.party.info[, 4])

tmp <- data.frame(x=1:15,
                  y=1:15,
                  z=factor(rep(c("Canada Party", "NDP", "Socialist"), each=5)))

ggplot(tmp, aes(x=x, y=y)) +
  geom_point(aes(color=z)) +
  scale_color_manual(values = fed.party.colors)

Best,
Ista

On Wed, Apr 3, 2013 at 9:08 AM, John Kane <jrkrideau at inbox.com> wrote:
> A stupid question but does anyone know how to express the actual colours used by the main Canadian political parties?   I want to do a couple of ggplot2 plots and have lines or rectangles that accurately reflect the party colours.
>
> I can probably play around with RColorBrewer or something to figure it out but if some some already has got them  it would save me some time especially with the NDP orange.
>
> Thanks
>
> John Kane
> Kingston ON Canada
>
> ____________________________________________________________
> FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
>
> ______________________________________________
> 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