0

I have x-axis value (as days) range from -1 to 300, code is like this

scale_x_continuous(breaks = scales::pretty_breaks(n = 10),limits=c(-1,290))

How can I label 0 to 'Baseline', and rest value no change, only label value 0?

The plot currently is like this:

enter image description here

cmirian
  • 2,572
  • 3
  • 19
  • 59
Ann
  • 13
  • 1
  • Hi @Ann. Welcome to StackOverflow. To improve your future question, please see this thread on how to make a great reproducible example https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – cmirian Jun 14 '20 at 08:42

1 Answers1

0

As I understand your question, you are seeking an answer on how to label x=0 as Baseline, while the remaining x-axis label text should remain as they are.

Data sample

set.seed(1)
df <- data.frame(y=sample(1:17,1000, replace=TRUE), x=sample(-1:300, 1000, replace=TRUE))

Gives

ggplot(df, aes(x=x, y=y=))

enter image description here

To manually alter the x-axis text, you could apply paste0

ggplot(df, aes(x=x, y=y)) +
  scale_x_continuous(breaks = seq(0,300,50),
                     labels = c(paste0("Baseline"), paste0(seq(50,300,50))))

Which gives

enter image description here

cmirian
  • 2,572
  • 3
  • 19
  • 59