0

I am trying to make a plot in r where the x-axis is time stamps from the vector called time. The values in time:

[1] "04:00:00" "06:00:00" "08:00:00" "10:00:00" "12:00:00" "14:00:00" "16:00:00" "18:00:00" "20:00:00" "22:00:00" "24:00:00"

However, the plot still put the values 2, 4, 6 and so on in between the time stamps? The code I use for the plot:

sumH1<-plot(tempsSumH1, type="l",xlab="Time",ylab="Temp")
axis(1,at=1:11,labels = time,tick = FALSE)

How the plot actually looks: Plot with tick marks.

Note that the even numbers do not necessarily need to be replaced with the time in the vector but can be left completely empty.

Jesper.Lindberg
  • 313
  • 1
  • 5
  • 14

1 Answers1

1

This happens because the plot command generates an entire plot, and then the axis command adds something to the existing plot. It does not alter what is already there. The numeric labels are drawn by the plot command, and you can hide them by setting xact = 'n'.

A. Stam
  • 2,148
  • 14
  • 29