36
36
# #' do.call(grid.arrange, c(plot.variance.decomposition(x), ncol = 4))
37
37
plot.variance.decomposition <- function (plot.inputs ,
38
38
fontsize = list (title = 18 , axis = 14 )){
39
+ require(ggmap )
40
+ theme_set(theme_classic() +
41
+ theme(axis.text.x = element_text(size = fontsize $ axis , vjust = - 1 ),
42
+ axis.text.y = element_blank(), axis.ticks = element_blank(), axis.line = element_blank(),
43
+ axis.title.x = element_blank(),
44
+ axis.title.y = element_blank(),
45
+ panel.grid.minor = element_blank(),
46
+ panel.border = element_blank()))
47
+
39
48
traits <- names(plot.inputs $ variances )
40
49
units <- as.character(trait.lookup(traits )$ units )
41
50
trait.labels <- as.character(trait.lookup(traits )$ figid )
@@ -51,38 +60,28 @@ plot.variance.decomposition <- function(plot.inputs,
51
60
decreasing = FALSE ), ]
52
61
53
62
base.plot <- ggplot(plot.data ) +
54
- coord_flip() +
55
- theme_bw() +
56
- opts(axis.text.x = theme_text(size = fontsize $ axis , vjust = - 1 ),
57
- axis.text.y = theme_blank(),
58
- axis.title.x = theme_blank(),
59
- axis.title.y = theme_blank(),
60
- panel.grid.minor = theme_blank(),
61
- panel.border = theme_blank())
62
-
63
- trait.plot <- base.plot +
64
- opts(title = ' Parameter' ,
65
- plot.title = theme_text(hjust = 0.96 , size = fontsize $ title ),
66
- axis.text.x = theme_text(colour = ' white' ),
67
- axis.line.x = theme_blank()) +
68
- geom_text(aes(y = 1 , x = points ,
69
- label = trait.labels , hjust = 1 ),
70
- size = fontsize $ axis / 3 ) +
71
- scale_y_continuous( breaks = c(0 ,0 ), limits = c(0 ,1 ))
72
-
73
- cv.plot <- base.plot +
74
- opts(title = ' CV (%)' , plot.title = theme_text(size = fontsize $ title )) +
75
- geom_pointrange(aes(x = points , y = coef.vars , ymin = 0 , ymax = coef.vars ),
76
- size = 1.25 )
63
+ coord_flip()
64
+
65
+
66
+ trait.plot <- base.plot + ggtitle(" Parameter" ) +
67
+ geom_text(aes(y = 1 , x = points ,
68
+ label = trait.labels , hjust = 1 ),
69
+ size = fontsize $ axis / 3 ) +
70
+ scale_y_continuous( breaks = c(0 ,0 ), limits = c(0 ,1 )) +
71
+ theme(axis.text.x = element_blank())
72
+ cv.plot <- base.plot + ggtitle(" CV (%)" ) +
73
+ geom_pointrange(aes(x = points , y = coef.vars , ymin = 0 , ymax = coef.vars ),
74
+ size = 1.25 ) +
75
+ theme(plot.title = element_text(size = fontsize $ title ))
76
+
77
77
78
- el.plot <- base.plot +
79
- opts( title = ' Elasticity ' , plot.title = theme_text (size = fontsize $ title )) +
78
+ el.plot <- base.plot + ggtitle( " Elasticity " ) +
79
+ theme( plot.title = element_text (size = fontsize $ title )) +
80
80
geom_pointrange(aes(x = points , y = elasticities , ymin = 0 , ymax = elasticities ),
81
81
size = 1.25 )
82
82
83
- pv.plot <- base.plot +
84
- opts(title = ' Root Variance (Mg/ha)' ,
85
- plot.title = theme_text(size = fontsize $ title )) +
83
+ pv.plot <- base.plot + ggtitle(" SD Explained (Mg/ha)" ) +
84
+ theme(plot.title = element_text(size = fontsize $ title )) +
86
85
geom_pointrange(aes(x = points , sqrt(variances ),
87
86
ymin = 0 , ymax = sqrt(variances )), size = 1.25 )
88
87
@@ -146,14 +145,13 @@ plot.sensitivity <- function(sa.sample, sa.spline, trait,
146
145
# indicate median with larger point
147
146
geom_point(aes(x ,y ), data = data.frame (x = sa.sample [median.i ], y = sa.spline(sa.sample [median.i ])), size = dotsize * 1.3 ) +
148
147
scale_y_continuous(limits = range(pretty(y.range )), breaks = pretty(y.range , n = 3 )[1 : 3 ]) +
149
- theme_bw() +
150
- opts(title = trait.lookup(trait )$ figid ,
151
- axis.text.x = theme_text(size = fontsize $ axis ),
152
- axis.text.y = theme_text(size = fontsize $ axis ),
153
- axis.title.x = theme_text(size = fontsize $ axis ),
154
- axis.title.y = theme_blank(),
155
- plot.title = theme_text(size = fontsize $ title ),
156
- panel.border = theme_blank())
148
+ theme_bw() + ggtitle(trait.lookup(trait )$ figid )
149
+ theme(axis.text.x = element_text(size = fontsize $ axis ),
150
+ axis.text.y = element_text(size = fontsize $ axis ),
151
+ axis.title.x = element_text(size = fontsize $ axis ),
152
+ axis.title.y = element_blank(),
153
+ plot.title = element_text(size = fontsize $ title ),
154
+ panel.border = element_blank())
157
155
# # Following conditional can be removed to only plot posterior sa
158
156
prior.x <- post.x
159
157
if (! is.null(prior.sa.sample ) & ! is.null(prior.sa.spline )){
1 commit comments
dlebauer commentedon Aug 14, 2014
Instructions for updating ggplot functions http://stackoverflow.com/a/21173744/199217