KDMS
KDMS

Reputation: 13

How to change the size of my Text in my plots legend

I want to increase the Textsize in my legend: enter image description here

As you can see in the picture, the size of the text is too small. Changing cex just increases the whole legend, which doesn't look well.

enter image description here

Is there a way to increase just the text size in the legend ?

Right now my plot code looks like this:

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)

Upvotes: 1

Views: 209

Answers (1)

Ferran
Ferran

Reputation: 840

Set pt.cex = 1 inside legend and then you can change cex without changing the whole legend size:

Example (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)

Upvotes: 1

Related Questions