Increase size of symbols in legend in a ggplot2 graph

Hi all;

I am trying to create a line plot (with symbols) and I am having trouble with the size of the symbols in the legend. No matter what I try to do, increasing the point size in the legend increases the LINE part of the legend symbol, which overwhelms the symbol itself. I tried taking out the line in the legend using geom_line(show.legend=F) , but that has no effect.

Here is my code:

fig3<-ggplot(data,aes(x=Time,y=Mean,ymin=LCI,ymax=UCI,group=Treatment)) + geom_line(aes(color=Treatment),show.legend=F)+
  geom_point(aes(color=Treatment, shape=Treatment,size=3))+geom_errorbar(width=0.2,size=0.8,aes(col=Treatment))+labs(title=NULL,x="Nominal Time (hrs)",y=expression(paste(Delta,Delta,"QTcI ","(msec)",sep="")))+
  scale_y_continuous(limits=c(-5,15))+geom_hline(yintercept=10,linetype=2,col="red")+
  theme(axis.text.x=element_text(size=12),axis.text.y=element_text(size=12),axis.title=element_text(size=12),plot.title=element_text(size=20),legend.text=element_text(size=12),legend.title=element_text(size=12))+
 guides(size=FALSE)+guides(color = guide_legend(override.aes = list(size = 4)))

You can see from the attached plot that the line overwhelms the symbols. I also tried
+guides(shape = guide_legend(override.aes = list(size = 4)))

but it again only seems to affect the line part of the legend symbols.

Any help at all would be greatly appreciated.

Not an answer to the actual question, but, in geom_point(), if you take size out of aes() (since it's not an aesthetic), you get a much better looking plot without touching the legend:

data  <-  tibble(Time = rep(0:4, 3),
              Treatment = rep(LETTERS[1:3], each = 5),
              Mean = rnorm(15, 7, 4),
              LCI = Mean - abs(rnorm(15, 2, 1)),
              UCI = Mean + abs(rnorm(15, 2, 1)))


ggplot(data,aes(x=Time,y=Mean,ymin=LCI,ymax=UCI,group=Treatment)) +
  geom_line(aes(color=Treatment))+
  geom_point(aes(color=Treatment, shape=Treatment), size=3)+
  geom_errorbar(width=0.2,size=0.8,aes(col=Treatment))+
  labs(title=NULL,x="Nominal Time (hrs)",
       y=expression(paste(Delta,Delta,"QTcI ","(msec)",sep="")))+
  scale_y_continuous(limits=c(-5,15))+
  geom_hline(yintercept=10,linetype=2,col="red")+
  theme(axis.text.x=element_text(size=12),
        axis.text.y=element_text(size=12),
        axis.title=element_text(size=12),
        plot.title=element_text(size=20),
        legend.text=element_text(size=12),
        legend.title=element_text(size=12))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.