[R] Canadian politcal party colours in ggplot2
John Kane
jrkrideau at inbox.com
Thu Apr 4 14:04:53 CEST 2013
Excellent. I never thought of something like that. Clearly I need to look into the XML package more closely.
The peculiar NDP orange comes through just great though for other readers, your example seems to assign the Canadian Alliance colours to the NDP. Quelle horreur!
John Kane
Kingston ON Canada
> -----Original Message-----
> From: istazahn at gmail.com
> Sent: Wed, 3 Apr 2013 09:43:25 -0400
> To: jrkrideau at inbox.com
> Subject: Re: [R] Canadian politcal party colours in ggplot2
>
> 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.
____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
More information about the R-help
mailing list