First, here's the dput of my data:
WaveletSite1Oxygen2 <- structure(list(Date = structure(c(741830400, 746668800, 749088000,
751507200, 753926400, 756345600, 759369600, 761788800, 764208000,
766627200, 770256000, 773366400, 778118400, 780537600, 782956800,
785462400, 790819200, 793238400, 795657600, 798681600, 801100800,
803865600, 807148800, 809568000, 812073600, 814406400, 817257600,
822873600, 825897600, 828316800, 831340800, 838598400, 841017600,
843436800, 846460800, 848880000, 851904000, 854323200, 855619200,
859334400, 864864000, 868320000, 872208000, 875491200, 877910400,
879379200, 883353600, 885772800, 888192000, 890611200, 893289600,
900028800, 904521600, 906940800, 909360000, 911779200, 912988800,
916617600, 919382400, 921456000, 925084800, 928108800, 930268800,
933292800, 935712000, 938131200, 941155200, 942364800, 949017600,
951436800, 953856000, 955065600, 964137600, 966556800, 970185600,
972604800, 973814400, 977443200, 979862400, 982800000, 985910400,
987984000, 990748800, 993168000, 994377600, 998092800, 1000512000,
1005350400, 1007769600, 1013817600, 1016236800, 1019260800, 1020297600,
1025308800, 1027728000, 1030147200, 1032566400, 1034985600, 1038614400,
1039824000, 1043452800, 1045872000, 1048291200, 1050624000, 1053129600,
1056758400, 1059177600, 1060387200, 1064016000, 1066435200, 1070064000,
1071273600, 1074902400, 1077321600, 1079740800, 1083024000, 1084579200,
1087948800, 1091232000, 1093651200, 1096070400, 1098489600, 1100908800,
1103328000, 1106352000, 1108771200, 1111190400, 1114819200, 1116028800,
1117843200, 1122076800, 1124496000, 1128038400, 1130544000, 1133222400,
1135123200, 1138665600, 1140566400, 1143244800, 1145577600, 1147996800,
1151107200, 1154131200, 1156550400, 1158883200, 1161388800, 1163808000,
1166140800, 1169164800, 1171670400, 1175299200, 1177632000, 1180051200,
1183161600, 1185580800, 1.188e+09, 1190419200, 1191628800, 1196294400,
1197676800, 1200614400, 1203120000, 1206748800, 1209168000, 1210377600,
1214006400, 1215129600, 1220054400, 1222473600, 1224892800, 1227312000,
1229731200, 1232755200, 1235174400, 1236384000, 1240012800, 1242432000,
1248480000, 1250553600, 1253318400, 1256947200, 1259280000, 1260576000,
1262995200, 1266710400, 1269043200, 1272326400, 1275091200, 1280534400,
1282953600, 1285372800, 1287792000, 1290211200, 1292544000, 1295568000,
1298073600, 1299283200, 1304035200, 1306454400, 1307664000, 1311638400,
1314057600, 1316476800, 1318809600, 1322611200, 1323820800, 1326499200,
1330473600, 1332892800, 1335312000, 1337731200, 1340064000, 1342569600,
1346112000, 1348531200, 1350950400, 1353542400, 1355788800, 1358985600,
1360022400, 1363392000, 1366070400, 1369699200, 1374710400, 1377216000,
1379030400, 1382054400, 1384473600, 1386892800, 1391126400, 1395360000,
1397779200, 1401235200, 1406246400, 1408579200, 1410998400, 1414713600,
1417046400, 1418428800, 1421712000, 1424044800, 1426723200, 1430352000,
1432944000, 1435276800, 1437523200, 1440028800, 1443398400, 1444867200,
1447372800, 1449619200, 1451952000, 1454976000, 1459382400, 1461715200,
1463011200, 1466726400, 1472601600, 1479168000, 1481155200, 1484179200,
1487721600, 1488931200, 1491350400, 1493769600, 1498780800, 1501027200,
1503446400, 1508544000, 1513296000, 1516060800, 1519171200, 1520812800,
1522886400, 1525219200), tclass = "Date", class = c("POSIXct",
"POSIXt")), AverageOxygen = c(4.11230769230769, 3.80128205128205,
3.64576923076923, 5.76538461538462, 5.23153846153846, 5.14807692307692,
4.26590909090909, 3.71666666666667, 4.35884615384615, 3.25769230769231,
4.85288461538462, 5.61923076923077, 4.35576923076923, 5.72884615384615,
7.22692307692308, 2, 4.21923076923077, 4.67211538461538, 5.125,
4.74230769230769, 4.28846153846154, 5.10384615384615, 6.06346153846154,
3.24230769230769, 6.07884615384615, 5.89615384615385, 4.54807692307692,
5.21442307692308, 5.48461538461538, 6.70769230769231, 5.36538461538461,
5.17483974358974, 5.95, 5.55384615384615, 5.67153846153846, 5.53769230769231,
5.78307692307692, 6.57307692307692, 6.49192307692308, 6.36153846153846,
6.71992307692308, 6.51936923076923, 6.41, 7.14782608695652, 6.11307692307692,
6.20961538461538, 6.85277777777778, 6.82277777777778, 6.82846153846154,
6.35384615384615, 5.15769230769231, 6.64, 6.39384615384615, 6.88179487179487,
6.44153846153846, 6.82192307692308, 7.45923076923077, 7.03730769230769,
7.01214285714286, 6.99326923076923, 6.83269230769231, 7.20188461538462,
5.94901602564103, 4.195, 5.11826923076923, 6.94230769230769,
6, 9.515, 7.95634615384615, 7.645, 6.72096153846154, 6.09538461538462,
6.65636639676113, 6.80596153846154, 6.19564102564103, 7.03442307692308,
6.52769230769231, 7.48740384615385, 7.22692307692308, 7.05307692307692,
6.06953846153846, 5.41384615384615, 7.17278846153846, 7.47373076923077,
7.1822792022792, 6.80788461538462, 7.24076923076923, 7.54961538461538,
5.55653846153846, 8.41923076923077, 6.75423076923077, 7.13653846153846,
7.00192307692308, 7.09538461538462, 7.29730769230769, 7.42903846153846,
5.87115384615385, 5.94153846153846, 6.42153846153846, 6.74269230769231,
5.88730769230769, 6.41692307692308, 6.82653846153846, 6.34096153846154,
6.19807692307692, 6.79384615384615, 6.56230769230769, 4.40576923076923,
6.54115384615385, 6.02884615384615, 5.75666666666667, 5.01076923076923,
5.55115384615385, 7.14961538461538, 5.77942307692308, 6.22141025641026,
6.66192307692308, 6.06788461538462, 5.91153846153846, 5.37692307692308,
5.61346153846154, 5.40192307692308, 6.41019230769231, 5.07961538461538,
5.09391025641026, 2.42012820512821, 1.75173076923077, 4.14705128205128,
4.44538461538462, 4.42269230769231, 2.94395833333333, 4.88153846153846,
5.15941483516484, 5.35596153846154, 5.26211538461538, 4.02961538461538,
2.60641254578755, 1.14916666666667, 4.67846153846154, 4.47653846153846,
3.97942307692308, 2.27812937062937, 1.98057692307692, 1.92730769230769,
4.65846153846154, 4.47173076923077, 5.02192307692308, 5.22423076923077,
4.07393162393162, 3.72826923076923, 3.01666666666667, 3.96634615384615,
4.85800480769231, 6.00442307692308, 6.44865384615385, 6.33692307692308,
5.90365384615385, 6.57846153846154, 5.57615384615385, 6.25384615384615,
5.31096153846154, 5.13022435897436, 4.98307692307692, 5.95038461538462,
4.89730769230769, 5.2225, 5.805, 5.91642081447964, 5.97115384615385,
5.25051282051282, 6.03519230769231, 5.66884615384615, 5.87538461538461,
6.06269230769231, 5.81807692307692, 5.94423076923077, 6.19153846153846,
5.54194762684124, 5.31923076923077, 6.35384615384615, 6.92051282051282,
7.19038461538462, 3.90384615384615, 7.64230769230769, 6.03589743589744,
6.51538461538462, 6.92820512820513, 6.81153846153846, 6.55897435897436,
6.36192307692308, 7.22307692307692, 6.10961538461538, 5.93653846153846,
6.85, 6.66538461538462, 5.12307692307692, 6.06153846153846, 6.42179487179487,
6.32051282051282, 5.85384615384615, 6.27307692307692, 7.02692307692308,
7.025, 6.02307692307692, 6.33173076923077, 6.47692307692308,
5.37884615384615, 2.38644688644689, 5.91538461538462, 5.31730769230769,
4.83461538461538, 1.25149572649573, 1.75757936507937, 2.47307692307692,
4.47115384615385, 4.81548717948718, 4.43502747252747, 5.33873626373626,
5.19423076923077, 5.90384615384615, 4.84038461538462, 5.45769230769231,
5.89487179487179, 1.63846153846154, 5.35576923076923, 7.03846153846154,
5.59230769230769, 5.84230769230769, 6.024, 3.81153846153846,
3.83846153846154, 5.7, 6.10769230769231, 5.32307692307692, 5.59423076923077,
6.86923076923077, 6.69028286528286, 6.57792022792023, 5.83846153846154,
3.90384615384615, 0.761111111111111, 3.08098290598291, 4.68205128205128,
4.51730769230769, 5.82692307692308, 1.52692307692308, 2.55769230769231,
2.41410256410256, 2.32142697881828, 2.16333333333333, 0.778571428571429,
1.40384615384615, 2.93846153846154, 2.74326923076923, 5.20769230769231,
3.86269230769231, 4.02076923076923, 2.32545833333333, 4.35038461538462,
5.60307692307692, 3.755, 5.00961538461539, 4.36307692307692,
3.245, 4.38769230769231, 3.26269230769231, 4.00121082621083,
4.79653846153846, 4.46518518518519, 5.34461538461538, 0.555384615384615,
2.92332867132867, 4.17307692307692, 4.87461538461538, 5.50230769230769
)), row.names = c(NA, -275L), class = "data.frame")
I'm using a package called WaveletComp to create wavelet graphs of my time series. The problem is, after I convert my time series into the wavelet analyzing function below and graph it, I can't change the time scale.
try <- analyze.wavelet(transform(WaveletSite1Oxygen2, date=Date), my.series="AverageOxygen", loess.span = 1/25,
dt = 1, dj = 1/250,
lowerPeriod = 2,
upperPeriod = 16,
make.pval = TRUE, method = "white.noise", params = NULL,
n.sim = 10,
verbose = TRUE)
#code for analyzing function
wt.image(try, periodlab = "periods",
+ legend.params = list(lab = "wavelet power levels"),
+ label.time.axis = TRUE,
+ show.date = TRUE, date.format = "%Y-%m")
# code for graph
The documentation says that once the date column is in POSIXct format, you should be able to manipulate it with the date.format command. However, the graph only shows the years in five-year intervals. So, it must be reading the column to some extent, but not fully?
Any help would be greatly appreciated!
To me, it seems to be a little bug, because I have not been able to find a solution.
But you can do this:
First:
1- Use trace(wt.image, edit=T)
2-go to line 395 of code and paste there:
plot(my.date, seq(min(axis.2),
max(axis.2), length.out = WT$nc), xlim = my.xlim,
ylim = my.ylim, type = "n", xaxs = "i", yaxs = "i",
yaxt = "n", xlab = "", ylab = "", lwd = lwd.axis,
tck = timetck, tcl = timetcl, mgp = par()$mgp -
c(0, 0.5, 0), font = par()$font.axis, cex.axis = par()$cex.axis,
axes = F)
axis(2, labels = F)
axis.POSIXct(1, at = seq(as.Date("1995-01-01",
format = "%Y-%m-%d", origin = as.Date("1970-01-01",
format = "%Y-%m-%d")), as.Date("2015-01-01",
, format = "%Y-%m-%d", origin = as.Date("1970-01-01",
format = "%Y-%m-%d")), length.out = WT$nc/5),
format = "%Y-%m", cex.axis = 1, las = 2)
Then, press save.
If you execute
wt.image(try, periodlab = "periods", n.levels = 200,
legend.params = list(lab = "wavelet power levels"),
label.time.axis = T,timelab = "",
show.date = T, date.format = "%Y-%m" )
You will get this:
You can change the font size of the labels by modifying cex.axis
, the number of labels shown be modifying length.out
and las
1 for vertical and 2 for horizontal labels
For full x-label ticks:
plot(my.date, seq(min(axis.2),
max(axis.2), length.out = WT$nc), xlim = my.xlim,
ylim = my.ylim, type = "n", xaxs = "i", yaxs = "i",
yaxt = "n", xlab = "", ylab = "", lwd = lwd.axis,
tck = timetck, tcl = timetcl, mgp = par()$mgp -
c(0, 0.5, 0), font = par()$font.axis, cex.axis = par()$cex.axis,
axes = F)
axis(2, labels = F)
axis.POSIXct(1, at = seq(as.Date("1993-07-01",
format = "%Y-%m-%d", origin = as.Date("1970-01-01",
format = "%Y-%m-%d")), as.Date("2018-05-01",
, format = "%Y-%m-%d", origin = as.Date("1970-01-01",
format = "%Y-%m-%d")), length.out = WT$nc/5),
format = "%Y-%m", cex.axis = 1, las = 2)
I am sorry I cannot give you a cleaner solution! Best