0

Very simple question here, but the answer continues to elude me. When I plot my data without specifying any x-axis labels, it plots with useless intervals (0.5, 1.5, 2.5) when my points of interest are 0, 1, and 2. When I use scale_x_discrete to relabel the tick marks, it always leaves the first mark blank and widens the range of the scale. Below is the code I'm using to attempt to relabel the tick marks. I can upload images of it with and without the scale_x code if that's helpful. Essentially, All I'm trying to do is relabel the tick marks like I relabeled the x-axis title.

plot2 <-
 ggplot(m1, aes(OPw, RTs)) +
 stat_summary(fun.y=mean, geom="point", fill="red", pch=21, size=3) + 
 geom_smooth(method = "lm") +
 scale_x_discrete(name="Ordinal Position Within-Novelty", 
               breaks=c("0", "1", "2"),
               labels=c("1", "2", "3"))
S.Faw
  • 1
  • 2
  • Welcome to SO! This community has a few [rules](https://stackoverflow.com/help/on-topic) and [norms](https://stackoverflow.com/help/how-to-ask), and following them will help you get a good answer to your question. In particular, it's best to provide an [MCVE](https://stackoverflow.com/help/mcve) (a minimum, complete, and verifiable example). Check out [this page](https://stackoverflow.com/a/5963610/4573108) for tips regarding R-specific MCVEs. Thanks and good luck! – mischva11 Aug 25 '18 at 19:48

1 Answers1

0

This was solved by removing the parentheses around the break values and specifying the limits at the same values as breaks and labels—FYI in case anyone else encounters the same error.

p2 <- ggplot(m1, aes(OPb, RTs)) +
  stat_summary(fun.y=mean, geom="point", fill="red", pch=21, size=3) + 
  geom_smooth(method = "lm") + 
  scale_x_discrete(name="Ordinal Position Between-Novelty",
               breaks=c(0, 1, 2, 3),
               labels=c(0, 1, 2, 3),
               limits=c(0, 1, 2, 3)) +
S.Faw
  • 1
  • 2