-----Original Message-----
From: patze003 at umn.edu
Sent: Fri, 19 Oct 2012 09:50:49 -0500
To: r-help at r-project.org
Subject: [R] Axis Breaks with ggplot2
R-help -
I'm trying to create axis breaks similar to this :
http://www.r-bloggers.com/wp-content/uploads/2010/08/bar-chart-natural-axis-split1.png
.
Is there a way to do this in R? Here's my code thus far:
structure(list(condition = structure(c(2L, 1L, 3L), .Label = c("con",
"exp", "unedit"), class = "factor"), trial.avg = c(4.04583333333333,
4.33541666666667, 4.61875), trial.sd = c(0.928718367573187,
0.851822141963017,
1.03502368980692), s.e. = c(0.0232179591893297, 0.0212955535490754,
0.163651614601074), N = c(40, 40, 40), condition2 = structure(1:3, .Label
=
c("Interaction Censured",
"Control Censured", "Uncensured"), class = "factor")), .Names =
c("condition",
"trial.avg", "trial.sd", "s.e.", "N", "condition2"), row.names = c(NA,
-3L), class = "data.frame")
library(ggplot2)
none <- theme_blank()
err1$condition <- as.factor(err1$condition)
censorA <- ggplot() + geom_bar(aes(y = trial.avg, x =
as.factor(condition2), fill = as.factor(condition2), position = "dodge"),
data = err1)
censorB <- censorA + geom_errorbar(aes(x = err1$condition2, ymin =
(err1$trial.avg-(err1$trial.sd/sqrt(40))), ymax = (err1$trial.avg+(err1$
trial.sd/sqrt(40))), data = err1, width = .4))
censorC <- censorB + opts(panel.background = none) + opts(panel.border =
none) + opts(panel.grid.minor = none) + opts(panel.grid.major = none) +
opts(axis.line = theme_segment(colour = "grey35")) + opts(background.fill
=
none)
censorC + scale_y_continuous(limits = c(0,7), expand = c(0,0), 'Rating')
+
opts(legend.position = "none")
Best,
--
Edward H. Patzelt
Research Assistant ? TRiCAM Lab
University of Minnesota ? Psychology/Psychiatry
VA Medical Center
S355 Elliot Hall: 612-626-0072
www.psych.umn.edu/research/tricam
[[alternative HTML version deleted]]