Difficulty with geom_dotplot

35 views
Skip to first unread message

Art

unread,
Mar 27, 2012, 10:49:50 AM3/27/12
to ggp...@googlegroups.com


Hello all,

I am having trouble getting separate dotplot columns to represent each variable in my variable column.  I just get three separate horizontal bands (no differentiation on the y axis).  Is there a problem with how my data are organized.  See dataframe dput and ggplot code.

Thanks for any help or advice.

Best,
Art


df dataframe...

structure(list(variable = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 
                                      1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 
                                      3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("center", "delay", 
                                      "no.barrier"), class = "factor"), value = c(3L, 4L, 3L, 7L, 4L, 
                                      3L, 8L, 14L, 4L, 3L, 29L, 35L, 30L, 28L, 21L, 21L, 35L, 29L, 
                                      33L, 35L, 8L, 9L, 10L, 15L, 21L, 36L, 27L, 27L, 11L, 14L)), .Names = c("variable", 
                                      "value"), row.names = c(NA, -30L), class = "data.frame")



ggplot(df, aes(x = factor(variable), y = "value")) +
  geom_dotplot(binaxis = "y", stackdir = "center")

Dennis Murphy

unread,
Mar 27, 2012, 1:35:42 PM3/27/12
to Art, ggp...@googlegroups.com
Hi:

Get rid of the quotes around value and you get the dotplot:

ggplot(df, aes(x = factor(variable), y = value)) +


geom_dotplot(binaxis = "y", stackdir = "center")

The clue is that the plot from your code returns a string constant
"value". Once you remove the quotes from value, it gets treated as a
numeric variable and the plot you expected is rendered.

Dennis

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

Art

unread,
Mar 27, 2012, 1:38:02 PM3/27/12
to ggp...@googlegroups.com


Dennis,


Thanks for the help! 
Reply all
Reply to author
Forward
0 new messages