Search code examples
rggplot2axis-labels

Renaming y axis ticks ggplot


I create the following plot: enter image description here

These ticks are generated automatically.

I'd like to rename the Y axis ticks with : 80000 to 1:20:000, 84000 to 1:24:000, 88000 to 1:28:000, 92000 to 1:32:000

This is my code:

seby_time<-ggplot(tempi_seb,aes(lap,milliseconds),color=position) + 
geom_point() +
geom_line(color="red")

I tried varius solutions but no one work.

Geom_line() or other type of "line functions" are required for this job.

Thanks


Solution

  • Use scale_y_continuous. Here is a minimal example

    library(ggplot2)
    
    ggplot(iris, aes(x = Petal.Length, y = Sepal.Length)) + geom_point() + 
      scale_y_continuous(breaks = c(5, 7), labels = c("5.0", "7.0"))
    

    enter image description here