0

I am using base plot to create a graphic showing two graphs (temperature and relative humidity) with two y axis and one common x axis showing the time. I limited the x axis from 0 to 24 so it is showing the hours of the day. My problem here is that the numbers shown on the x axis only range from 0 to 20 in steps by 5 but i want to show the numbers in steps by 3 ending by 24, in order to get a nice time axis from 0 to 24.

How can i set the X-Axis to look like this?

This is my plot

enter image description here

This is the code I used so far:

    ### Plot 1

  d1 = data.frame(Uhrzeit =D.Log.1t$Uhrzeit,
                 Temperatur = D.Log.1t$Temperatur,
                 rH = D.Log.1r$RH)


  par(mar = c(5,5,5,5))
  with(d1, plot(Uhrzeit, Temperatur, type="l", col="red3", 
                 ylim=c(0,40), xlim=c(0,24)))

  par(new = T)
  with(d1, plot(Uhrzeit, rH,  axes=F, type="l",  col="blue",
               ylim=c(0, 100)))
  axis(side = 4)
  mtext(side = 4, line = 3, 'rH')
  par(mar=c(5.1, 14, 4.1, 8.1), xpd=TRUE)
  legend("top",  inset=c(0,-0.2), legend=c("Temperatur in °C","rH in %"), lty=c(1, 1), col=c("red3", "blue"))
user20650
  • 24,654
  • 5
  • 56
  • 91
Gabba
  • 13
  • 7
  • Have a look at `?axis`, particularly the `at` and `labels` arguments.( oh also suppress the xaxis in your first plot call `xaxt="n"`) – user20650 Jul 06 '16 at 11:33
  • 1
    Thank you! Suppressing the x-axis and then plotting it with axis worked perfectly – Gabba Jul 06 '16 at 12:51

0 Answers0