[R] different values under the x axis labels
Robert Baer
rbaer at atsu.edu
Sat Nov 7 01:07:27 CET 2009
I have a .xls source file from 1 to 3600 seconds, each second has a noise
level value. (attached in case you are interested)
Imported as "Dataset".
I would like to make a graph: Here is what I have been able to use:
par(mar = c(5, 4, 4, 2) + 0.1)
plot(Dataset, type="l", xlab="čas [s]", ylab= expression(paste("Hladina
akustického tlaku"," ", bold(L[pA])," [dB]")), col="blue",
xlim=c(0,3600), ylim=c(35,60), xaxs = "i", yaxs = "i",cex.main=1.5,
cex.lab=1.2,xaxt="n")
abline(h=43,col="red",lwd=2)
title(main = "Místo příjmu 3, čas 9:00 - 10:00",font.main="2", line=3)
axis(3, xaxp=c(0, 3600, 12), mgp=c(3,0.6,0))
axis(1, xaxp=c(0, 3600, 12), mgp=c(3,0.6,0))
smartlegend(x="left", y="top",c(expression(paste(bold(L[eqA.1h]),bold("
[dB]"))), expression(paste(bold(L[pA]),bold(" [dB]")))),col=c("red","blue"),
lty= 1:1,lwd=2, y.intersp= 1.1, bg="grey96",cex=1.1)
I succeeded in changing scale on both "X" after 300 seconds and now I would
like to swap the value 300, 600, 900 (seconds)of the top axis to 5, 10, 15
(minutes) and so on OR
the best of all would be to have these numbers (minutes) under the original
bottom x axis values in different color.
Does this get you started?
Dataset=data.frame(time=1:3600,noise=15*abs(rnorm(3600)))
plot(Dataset, type="l", xlab="čas [s]", ylab= expression(paste("Hladina
akustického tlaku"," ", bold(L[pA])," [dB]")), col="blue",
xlim=c(0,3600), ylim=c(35,60), xaxs = "i", yaxs = "i",cex.main=1.5,
cex.lab=1.2,xaxt="n")
abline(h=43,col="red",lwd=2)
title(main = "Místo příjmu 3, čas 9:00 - 10:00",font.main="2", line=3)
# axis(3, xaxp=c(0, 3600, 12), mgp=c(3,0.6,0))
axis(3, at=seq(0,3600,300), labels=seq(0,60,5))
axis(1, xaxp=c(0, 3600, 12), mgp=c(3,0.6,0))
Rob
More information about the R-help
mailing list