[R] ggplot2 - how to change location / position of wind rose axis labels?

Darren Norris doon75 at hotmail.com
Sat Jan 24 01:39:03 CET 2009


Dear R users,
First just want to say thank you to all for developing such a wonderful
software and packages.

I need to produce a wind rose plot. Tried with packages circular and plotrix
and couldn't quite get what I want. Moved to package ggplot2 and it's going
great. However stuck in how to move axis labels.

I am using the wind rose from the help to learn how to do what I need (code
example below). The plot produced has axis labels on top of the axis line
(not sure if it's actually the plot or axis line...) - which means the
labels are unclear for what I need to produce. 

How can I move the labels to be outside of the line? I have read the online
book ( http://had.co.nz/ggplot2/book/ ), help, tried changing various theme
and scale settings and searched the package website and mailing list (
http://had.co.nz/ggplot2/ ). If the answer is there I'm too stupid to see it
- do I need to play with grobs? If so how? 

Any help much appreciated,
Darren

R version 2.8.1 (2008-12-22) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
Kingdom.1252;LC_MONETARY=English_United
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods  
base     

other attached packages:
[1] ggplot2_0.8.1 reshape_0.8.2 plyr_0.1.4    proto_0.3-8 


#Using an example form the coord_polar help
library(ggplot2)
movies$rrating <- factor(round_any(movies$rating, 1))
movies$budgetq <- factor(chop(movies$budget, 4), labels = 1:4)
doh <- ggplot(movies, aes(x = rrating, fill = budgetq))
doh + geom_bar(width = 1) + coord_polar()

#Now with my theme (hacked from theme_bw) getting close to what I need

theme_bwdn<-function (base_size = 12) 
{
    structure(list(axis.line = theme_blank(), axis.text.x = theme_text(size
= base_size * 
       1, lineheight = 0.9, vjust = 1), axis.text.y = theme_blank(),
axis.ticks = theme_segment(colour = "black", 
        size = 0.2), axis.title.x = theme_blank(), axis.title.y =
theme_blank(), axis.ticks.length = unit(0, 
        "lines"), axis.ticks.margin = unit(0, "lines"), legend.background =
theme_rect(colour = NA), 
        legend.key = theme_rect(colour = "grey80"), legend.key.size =
unit(1.2, 
            "lines"), legend.text = theme_text(size = base_size * 
            0.8), legend.title = theme_text(size = base_size * 
            0.8, face = "bold", hjust = 0), legend.position = "right", 
        panel.background = theme_rect(fill = "white", colour = NA), 
        panel.border = theme_rect(fill = NA, colour = "grey50"), 
        panel.grid.major = theme_line(colour = "black", size = 0.2), 
        panel.grid.minor = theme_line(colour = "black", size = 0.5), 
        panel.margin = unit(0.25, "lines"), strip.background =
theme_rect(fill = "grey80", 
            colour = "grey50"), strip.label = function(variable, 
            value) value, strip.text.x = theme_text(size = base_size * 
            0.8), strip.text.y = theme_text(size = base_size * 
            0.8, angle = -90), plot.background = theme_rect(colour = NA), 
        plot.title = theme_text(size = base_size * 1.2), plot.margin =
unit(rep(0.5, 
            4), "lines")), class = "options")
}

awind<-doh + geom_bar(width = 1) + coord_polar()

#produces the wind rose but how to move axis labels?
awind + theme_bwdn()




-- 
View this message in context: http://www.nabble.com/ggplot2---how-to-change-location---position-of-wind-rose-axis-labels--tp21635526p21635526.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list