我有以下数据为代表的多变量数据集:轴线不与日期标签绘制
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)
我绘制在同一地块的所有变量(A,B,..等)。这里是我的代码,它的工作原理:
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)
我试过的功能轴添加x轴,如以下,但在x轴没有表现出向上
axis(side = 1, at = seq(1,12), labels = Labels)
然后我试图axis.Date函数我得到一个错误'origin'必须被提供。
axis.Date(side = 1, x = Labels, at = seq(1,12), format = "%m/%y", origin = "2011-07-03")
我需要的是:(1)12日期标签“标签”与在45度和(2)格式化的y轴显示在$ 100,000个蜱金融数据倾斜于x轴12的刻度线,(3)请帮我理解我的错误。
非常感谢提前。
我非常感谢lukeA,斯文海恩斯坦和亨里克技术知识和他们的时间。 –