I have a variable used in a script that defines labels for some test
conditions:
testCondition = c("21-OC","21-SH","41-OC","41-SH","70-OC","70-SH")
I reference this variable in a section of code that was designed to
place labels on a graph by calling the following code:
annotate("text",x=seq(1,length(unique(results
$test_cond)),by=1),y=1.0,label=unique(testCondition),
colour="grey50",size=3)
This used to work with no issues. Now when I run the entire code it
returns the following error:
Error: When _setting_ aesthetics, they may only take one value.
Problems: label
Can someone point out why this no longer works and what I can do to
correct it? Thanks in advance!
For your case, I'd recommend just using an ordinary layer:
testCondition = c("21-OC","21-SH","41-OC","41-SH","70-OC","70-SH")
labels <- data.frame(
x = seq_along(testCondition),
y = 1,
label = testCondition)
... + geom_text(aes(x, y, label = label), data = testCondition,
colour="grey50",size=3)
Hadley
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> To post to this group, send email to ggp...@googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
Any suggestions on what class the variables "testCondition" need to be
in? I did as you suggest but now am getting the following error:
"Error: ggplot2 doesn't know how to deal with data of class character"
I also tried the following:
+ geom_text(aes(x, y, label = label), data =
as.factor(testCondition),colour="grey50",size=3) and get the error
"Error: ggplot2 doesn't know how to deal with data of class factor"
It should be data = labels, not data = testConditon.
Hadley