I have a multivariate data set typified by the data below:
financials <-
"A B C D E Dates
52730.1 104761.1 275296.1 569423.1 1136638.1 2013-12-2
77709 97940 275778 515095 1075166 2013-08-04
102734 71672 227017 482068 1011764 2013-03-17
96345 74035 240334 429026 998734 2012-10-28
98651 62305 236694 436948 962913 2012-06-10
78804 73568 242068 471640 945891 2012-01-22"
fData <- read.table(text = financials, header = TRUE)
I plot all variables (A, B,.. etc) on the same plot. Here is my code and it works:
range <- range(fData[,-6])
fData$Dates <- as.Date(fData$Dates, origin = "2011-07-03")
Labels <- seq(as.Date("2012-01-22", origin = "2011-07-03"),
to = as.Date("2013-12-2",origin = "2011-07-03"),
by = "2 months")
plot(A ~ Dates, fData, type = "o", col = "red", ylim = range, xaxt="n", pch = 10)
points(B ~ Dates, fData, type = "o", col = "green", pch = 11)
points(C ~ Dates, fData, type = "o", col = "black", pch = 12)
points(D ~ Dates, fData, type = "o", col = "blue", pch = 13)
points(E ~ Dates, fData, type = "o", col = "magenta", pch = 14)
I tried the function axis to add the x-axis, as below, but the x-axis did not show-up
axis(side = 1, at = seq(1,12), labels = Labels)
Then I tried axis.Date function I got an error 'origin' must be supplied.
axis.Date(side = 1, x = Labels, at = seq(1,12), format = "%m/%y", origin = "2011-07-03")
What I need is: (1)12 date labels "Labels" with 12 tick marks on the x-axis SLANTED at 45 degrees and (2) format the y-axis to display financial data in $100,000 ticks, (3) please help me understand my mistakes.
Many thanks in advance.
See Question&Answers more detail:
os