2013-01-16 65 views
13

私はggplotコードを持っており、x軸とy軸のラベルのサイズを変更したいと考えました。x軸とy軸のラベルのサイズR

コード:

df.m <- melt(df, names(df)[2:3], names(df)[1]) 
df.m$Results <- factor(df.m$Results) 
df.m$HMn25_30.h <- strptime(as.character(df.m$HMn25_30.h), format = "%Y-%m-%d %H:%M:%S") 
p <- ggplot(df.m, aes(x = HMn25_30.h, y = value, group = variable, color = variable)) 
p <- p + scale_shape_manual(values=c(20,22)) 
p <- p + geom_point(aes(shape = Results), cex=4, color= "blue3") 
p <- p + geom_line(size=.8) 
p <- p + theme(axis.text.x = element_text(angle = 90, hjust = 1, size=13,color="darkred")) 
p <- p + scale_color_manual(values=c("Red")) 
p <- p + ylim(-1,8) 
p <- p + xlab('Date and Time') 
p <- p + ylab('Temperature') 
p <- p + ggtitle("Temporal Outliers of Node 25 ") + theme(plot.title = element_text(lineheight=3, face="bold", color="black", size=29)) 
p 

言い換えると「温度」と「日付と時刻」フォントとサイズでは変更する必要があります。あなたがthemeの異なるオプション適用することができます

+2

をあなたはtheme'既に '関数を使用しているが、あなたはそれがドキュメントだ読んだことがあるようには見えません。今はそうすることをお勧めします。私はあなたがそれが啓発であると思うと思う。 – joran

答えて

32

p <- ggplot(df.m, aes(x = HMn25_30.h, y = value, group = variable, color = variable)) 
    p <- p + scale_shape_manual(values=c(20,22)) 
    p <- p + geom_point(aes(shape = Results), cex=4, color= "blue3") 
    p <- p + geom_line(size=.8) 
    p <- p + theme(axis.text.x = element_text(angle = 90, hjust = 1, size=13,color="darkred")) 
    p <- p + scale_color_manual(values=c("Red")) 
    p <- p + ylim(-1,8) 
    p <- p + theme_bw() 
    p <- p + xlab('Date and Time') 
    p <- p + ylab('Temprature') 
    p <- p + ggtitle("Temporal Outliers of Node 25 ") + theme(plot.title = element_text(lineheight=3, face="bold", color="black", size=29)) 
    p <- p + labs(x = "Date-Time ", y = "Temprature ") 
    p <- p + theme(axis.title.y = element_text(size = rel(1.8), angle = 90)) 
    p <- p + theme(axis.title.x = element_text(size = rel(1.8), angle = 00)) 
    p 
+0

これらは、次のような単一の 'theme()'呼び出しでも適用できます: 'テーマ(scale_shape_manual(値= c(20,22))、 geom_point(エース(形状=結果)、cex = 4、カラー= "blue3")、 etc' – DirtStats

+0

'theme(text = element_text(size = 15))'というプロットのすべてのテキスト要素を変更するための単一の 'theme()'呼び出し。 –

関連する問題