Setting Aesthetics Error

Skip to first unread message

Nick S

Feb 17, 2010, 7:55:35 PM2/17/10
to ggplot2
Apologies for not posting my entire code...but hopefully I have
provided enough for someone to tell me what I am missing.

I have a variable used in a script that defines labels for some test
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:

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!

hadley wickham

Feb 18, 2010, 8:40:43 AM2/18/10
to Nick S, ggplot2
Hi Nick,

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,


> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> To post to this group, send email to
> To unsubscribe from this group, send email to
> For more options, visit this group at

Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University

Nick S

Feb 23, 2010, 12:07:36 PM2/23/10
to ggplot2
Many thanks for the reply Hadley.

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"

hadley wickham

Feb 23, 2010, 1:27:18 PM2/23/10
to Nick S, ggplot2

It should be data = labels, not data = testConditon.


Reply all
Reply to author
0 new messages