![](/img/trans.png)
[英]how to change legend, country labels and size of my multiple area plots with ggplot2?
[英]How to change the size of my Text in my plots legend
正如您在图片中看到的,文本的大小太小。 更改 cex 只会增加整个图例,这看起来不太好。
有没有办法只增加图例中的文本大小?
现在我的情节代码如下所示:
par(font.main=3, font.lab=1, font.sub=1, cex.main=2, cex.lab=1.7, cex.sub=1.2)
plot(plot.DE$Monat,cumsum(log10(1+plot.DE$`12.2`)),type="l",col="blue",main="Momentum-Performance Deutschland",ylab="Portfolio Wert",xlab="Jahr",ylim=c(-0.5,2.5),yaxt ="n"
,cex.main=1.5,cex.lab=1,cex.axis=1)
lines(plot.DE$Monat,cumsum(log10(1+plot.DE$`12.7`)),type="l",col="green")
lines(plot.DE$Monat,cumsum(log10(1+plot.DE$`6.2`)),type="l",col="red")
lines(plot.DE$Monat,cumsum(log10(1+plot.DE$Markt)),type="l",col="yellow")
legend("topleft",legend = c("12-2","12-7","6-2","Markt"),col = c("blue","green","red","yellow"),adj = c(0, 0.5),pt.cex = cex,lty=1, cex=1,bg="grey",y.intersp = 0.8,x.intersp = 1.2)
axis(2, at=seq(0,2,by=1),labels=c("1$","10$","100$"), col.axis="black", las=2,cex.axis=1)
在图例中设置pt.cex = 1
,然后您可以更改cex
而不更改整个图例大小:
示例 (cex=1.5):
par(font.main=3, font.lab=1, font.sub=1, cex.main=2, cex.lab=1.7, cex.sub=1.2)
plot(plot.DE$Monat,cumsum(log10(1+plot.DE$`12.2`)),type="l",col="blue",main="Momentum-Performance Deutschland",ylab="Portfolio Wert",xlab="Jahr",ylim=c(-0.5,2.5),yaxt ="n"
,cex.main=1.5,cex.lab=1,cex.axis=1)
lines(plot.DE$Monat,cumsum(log10(1+plot.DE$`12.7`)),type="l",col="green")
lines(plot.DE$Monat,cumsum(log10(1+plot.DE$`6.2`)),type="l",col="red")
lines(plot.DE$Monat,cumsum(log10(1+plot.DE$Markt)),type="l",col="yellow")
legend("topleft",legend = c("12-2","12-7","6-2","Markt"),col = c("blue","green","red","yellow"),pt.cex = 1, cex=1.5,adj = c(0, 0.5),lty=1, ,bg="grey",y.intersp = 0.8,x.intersp = 1.2)
axis(2, at=seq(0,2,by=1),labels=c("1$","10$","100$"), col.axis="black", las=2,cex.axis=1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.