1

I'm trying to figure out how to manipulate the axis labels that are produced when using scale_y_time() in ggplot2. For example, I would like to change the y-axis label produced by the code below to be just "minutes and seconds" ("%M:%S")

Here is a simple example of the kind of plot I am making, with data that represents a "starting point" (start) and "ending point" (end) and time tag in seconds that goes with each starting point (time).

library(tidyverse)

start <- seq(1, 105, 5)
end <- seq(3, 103, 5)
time = seq(0, 360, 18)

dat <- data.frame(start, end, time)

ggplot(dat) + 
  geom_segment(aes(x = start, y = time, xend = end, yend = time)) +
  scale_y_time()

1 Answer 1

2

+ scale_y_time(labels = function(t) strftime(t, "%M:%S")) should yield:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.