annotate error: Discrete value supplied to continuous scale

842 views
Skip to first unread message

bdmccu...@drexel.edu

unread,
Aug 28, 2016, 1:04:46 AM8/28/16
to ggplot2
All I want to do is put the word "alpha" at the position (-2.5, 0.2) on this graph, and I can't figure out what is causing the error.

library(ggplot2)
myx <- seq(-4,4,0.01)
myy <- dnorm(myx)
df <- as.data.frame(cbind(myx,myy))
ggplot(df,aes(myx,myy)) +  geom_point() + annotate("text",x=-2.5,y=0.2,"alpha")

All I get is:
Error: Discrete value supplied to continuous scale


I have found many complex discussions of this particular error message, but none related to so simple a case as mine, and none relating to annotate.

Many thanks for any help.

Tom Philippi

unread,
Aug 28, 2016, 1:43:34 AM8/28/16
to bdmccu...@drexel.edu, ggplot2
annotate() has a bunch of other parameters you are omitting, so you need to tell it which parameter "alpha" is a value for:
ggplot(df,aes(myx,myy)) +  geom_point() + annotate("text",x=-2.5,y=0.2,label="alpha")

?annotate

--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages