이 시도 :
ts1 <- rnorm(100) # randomly generated values for times series
ts2 <- rnorm(100)
ts3 <- rnorm(100)
ts4 <- rnorm(100)
library(TTR)
df <- data.frame(time=rep(1:100, 8),
id=as.factor(rep(1:8, each=100)), id1=as.factor(rep(1:4, each=200)),
type=as.factor(rep(rep(1:2, each=100),4)),
value=c(ts1, SMA(ts1), ts2, SMA(ts2), ts3, SMA(ts3), ts4, SMA(ts4)))
library(ggplot2)
ggplot(df, aes(time, value, col=type, group=id)) +
geom_line() + facet_wrap(~id1, ncol=1) +
scale_color_manual(values=c('green', 'red'))+
guides(color=FALSE) + theme_bw() + theme(strip.text = element_blank())
당신이 측면에 대해 서로 다른 Y 레이블을 원하는 경우,이 시도 : 왜 질문은
library(grid)
library(gridExtra)
grid.arrange(ggplot(data.frame(time=rep(1:100, 2), id=as.factor(rep(1:2, each=100)),
type=as.factor(rep(1:2, each=100)),
ts1=c(ts1, SMA(ts1))), aes(time, ts1, col=type, group=id)) +
geom_line() + scale_color_manual(values=c('green', 'red')) + guides(color=FALSE) +
theme_bw() + theme(axis.text.x = element_blank(), axis.ticks = element_blank()) + xlab(''),
ggplot(data.frame(time=rep(1:100, 2), id=as.factor(rep(1:2, each=100)),
type=as.factor(rep(1:2, each=100)),
ts2=c(ts2, SMA(ts2))), aes(time, ts2, col=type, group=id)) +
geom_line() + scale_color_manual(values=c('green', 'red')) + guides(color=FALSE) +
theme_bw() + theme(axis.text.x = element_blank(), axis.ticks = element_blank()) + xlab(''),
ggplot(data.frame(time=rep(1:100, 2), id=as.factor(rep(1:2, each=100)),
type=as.factor(rep(1:2, each=100)),
ts3=c(ts3, SMA(ts3))), aes(time, ts3, col=type, group=id)) +
geom_line() + scale_color_manual(values=c('green', 'red')) + guides(color=FALSE) +
theme_bw() + theme(axis.text.x = element_blank(), axis.ticks = element_blank()) + xlab(''),
ggplot(data.frame(time=rep(1:100, 2), id=as.factor(rep(1:2, each=100)),
type=as.factor(rep(1:2, each=100)),
ts4=c(ts4, SMA(ts4))), aes(time, ts4, col=type, group=id)) +
geom_line() + scale_color_manual(values=c('green', 'red')) + guides(color=FALSE) + theme_bw(), ncol=1)
을을 downvoted입니까? ? – Vini
베이스 R에서 x 축 레이블이나'plot (1:10, 1:10, xlab = "", xaxt = "n")을 제거하려면'plot (1:10, 1:10, xlab = "")'을 눌러 레이블 및 눈금 표시 레이블을 제거하십시오. – lmo
레이블과 X 축의 색인을 제거 할 수 있습니다. 그러나 나는 하나의 그래프로 4 개의 그림을 동시에 얻을 수는 없다. – Vini