0
이 분석을 R로 구현하고 있습니다. 데이터 세트를 다운로드하고 동물원 개체를 만들고 데이터 집합을 그립니다. 더 나은 보이는 그래프를 제시하기 위해다중 행 y 레이블이있는 그림 맞추기
library(tseries)
library(zoo)
start <- "2011-01-01"
end <- "2014-12-31"
MET <- get.hist.quote("MET", quote="Close", start=start, end=end)
MHK <- get.hist.quote("MHK", quote="Close", start=start, end=end)
MJN <- get.hist.quote("MJN", quote="Close", start=start, end=end)
MKC <- get.hist.quote("MKC", quote="Close", start=start, end=end)
MLM <- get.hist.quote("MLM", quote="Close", start=start, end=end)
MMC <- get.hist.quote("MMC", quote="Close", start=start, end=end)
MMM <- get.hist.quote("MMM", quote="Close", start=start, end=end)
MNK <- get.hist.quote("MNK", quote="Close", start=start, end=end)
MNST <- get.hist.quote("MNST", quote="Close", start=start, end=end)
MO <- get.hist.quote("MO", quote="Close", start=start, end=end)
MON <- get.hist.quote("MON", quote="Close", start=start, end=end)
MOS <- get.hist.quote("MOS", quote="Close", start=start, end=end)
MPC <- get.hist.quote("MPC", quote="Close", start=start, end=end)
MRK <- get.hist.quote("MRK", quote="Close", start=start, end=end)
MRO <- get.hist.quote("MRO", quote="Close", start=start, end=end)
Series <- zoo(cbind(MET, MHK, MJN, MKC, MLM, MMC, MMM, MNK, MNST, MO,
MON, MOS, MPC, MRK, MRO))
colnames(Series) <- c("MetLife", "Mohawk", "\nMead\nJohnson",
"McCormick", "Martin\nMarietta",
"Marsh and\nMcLennan", "3M", "Mallinckrodt",
"Monster\nBeverage", "Altria", "Monsanto",
"The Mosaic\nCompany", "Marathon\nPetroleum",
"Merck", "Marathon Oil")
Series <- na.approx(Series)
plot(Series, main = "", xlab = "")
, 나는이 개 라인에서 y를 레이블 이름을 분할 명령 \n
을 도입했습니다. 그러나 그래픽 출력은 왼쪽 y 레이블을 여백에서 제외시킵니다.
내 모든 출력의 변화없이 기능 par()
에 마르와 마이 모두를 수정하는 것을 시도했다. 나는 이것이 아마도 객체 (동물 객체)에 연결될 수 있다고 생각한다.
나는 ggplot2에 대해서도 생각하고있었습니다. 그러나 나는 정상적인 음모에 의해 주어진 출력을 선호합니다. ggplot을 사용하여 모든 Y 축척을 부드럽게 유지합니다. 위 이미지의 여백을 수정하는 데 도움을 주시겠습니까? –
'facet_wrap (.., scales = "free_y")';)와 같은 소리가납니다. 죄송합니다, 나는/전혀 기본 그래픽을 알지는 못하지만'동물원'은'par()'설정을 무시할 수있는 자신의'plot' 방법을 가지고있을 것이라고 생각합니다. – liborm
약간의 인터넷 검색 후 [this] (https://timelyportfolio.github.io/rCharts_time_series/history.html)에서 autoplot.zoo()를 사용하면 데이터를 쉽게 그릴 수 있습니다. – liborm