1

In ggplot2 I want to display

(1) all the values in x-axis 1,2,....,15

(2) raw number instead of the scientific notation

enter image description here

Below is my code

cycle_time <- 1:15
volume <- c(109.12,381.11,812.31,1109,4439.32, 12148.29,32514.32,82231.24,183348.44,329472.36,462381.96,541111.67,
            576516.09, 590450.40,595642.83)

dfx <- data.frame(as.factor(cycle_time),volume)

p1<- ggplot(dfx, aes(cycle_time,volume)) + geom_line()
p1

Please share your full code

Thanx in advance

RayX500
  • 247
  • 2
  • 10
  • Do these two questions/answers solve your problem? [How to disable scientific notation?](https://stackoverflow.com/questions/5352099/how-to-disable-scientific-notation) and [Set breaks between values in continuous axis of ggplot](https://stackoverflow.com/questions/70978496/set-breaks-between-values-in-continuous-axis-of-ggplot) – jared_mamrot Apr 29 '22 at 01:27
  • @ jared_mamrot Thanks, this fixes the `Y` axis. Any suggestion for `X` axis? I want to display all the values in `cycle_time` - `1`,`2`,.......`15`. – RayX500 Apr 29 '22 at 01:30
  • 1
    for the x-axis `+ scale_x_continuous(breaks = cycle_time)` – neilfws Apr 29 '22 at 01:31

1 Answers1

1
cycle_time <- 1:15
volume <- c(109.12,381.11,812.31,1109,4439.32, 12148.29,32514.32,82231.24,183348.44,329472.36,462381.96,541111.67,
            576516.09, 590450.40,595642.83)

dfx <- data.frame(cycle_time,volume)

p1<- ggplot(dfx, aes(cycle_time,volume)) + geom_line()
p1 +
  scale_x_continuous(breaks=seq(1,15,1))+
  scale_y_continuous(labels=scales::comma)

Created on 2022-04-29 by the reprex package (v2.0.1)

YH Jang
  • 1,306
  • 5
  • 15