0

I am creating a dot plot using ggplot2 something like this:

ggplot(data=GraphData, aes(x = VisitXC, y = DoseNormConc, fill = Study)) +
  geom_dotplot(binaxis = 'y', stackdir = 'up', dotsize = 4, 
               position = "dodge", binwidth=5) +
  scale_fill_manual(values = c("blue", "red","green", "purple", "orange"))

I am currently stuck in two things:

  1. How to order the Study in a particular order as currently it is displaying in alphabetical order, and I need to display the dots in a specific Study order

  2. I was able to display N on top of each dotpot using the following

Code:

geom_text(data = GraphData, 
          aes(x = factor(VisitXC), y = 1200, label = paste0("N=", NSub), color = color), 
          position = position_dodge(width = 1), show.legend = F)

but the color of each N=XX on top of the dots are not consistent with the colors I have chosen to display.

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
SFO
  • 3
  • 4
  • 3
    Welcome to Stackoverflow. Please have a look at how to create a [minimal reproducible example](https://stackoverflow.com/help/mcve) and also how to write a [good R example](https://stackoverflow.com/q/5963269/3250126). Only thus others are able to help you. – loki Feb 06 '18 at 07:53
  • `+ scale_color_manual(values = c("blue", "red","green", "purple", "orange"))`. The `fill` and `color` aesthetics are different, and you need to set both scales to get the same colors showing up. This is my best guess, no testing or full answer possible without a reproducible example. – Axeman Feb 06 '18 at 09:15

0 Answers0