2

I have a graph where two legends are present. I need to change the size of the points of one of the legends.

enter image description here

I need to change the bullet size of "market type" in the legend. I use the example here but does not work for my graph.

My code is below:

k <- ggplot(subsetdf) + theme_bw() +
  geom_point(      aes(y=y, x=x, size =Total.Unit.Count, fill = region), shape=21)+

  scale_colour_hue(aes(y=y, x=x),l=50) + # Use a slightly darker palette than normal

  geom_text_repel (aes(y=y, x=x, label = rownames(subsetdf))) +
  geom_smooth(aes(x=x, y=y),method=lm,   # Add linear regression lines
  se=FALSE)  +
  labs(y = "title", x = "title",
       title = "title",
       size = "size", fill = "fill")+
  theme(plot.title = element_text (face = 'bold',size = 21,hjust = 0.5),
        legend.text = element_text(size = 16),
        legend.title = element_text(size = 18),
        axis.title.x = element_text(size=20),
        axis.title.y = element_text(size=20),
        axis.text.x = element_text(size = 18,angle=45, hjust=1),
        axis.text.y = element_text(size = 18,hjust = 1),
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank())+
        scale_size_continuous(range = c(3,8))+
  guides(colour = guide_legend(override.aes = list(size=10)))
Community
  • 1
  • 1
DataTx
  • 1,839
  • 3
  • 26
  • 49

1 Answers1

6

You used the fill aesthetic guide, not color. So that is the guide to override.

Below is an example with iris dataset, as you code is not reproducible.

library(ggplot2)

ggplot(iris) +
    geom_point(aes(Sepal.Length, Petal.Length, size = Sepal.Width, fill = Species), shape = 21) +
    guides(fill = guide_legend(override.aes = list(size=8)))

GGamba
  • 13,140
  • 3
  • 38
  • 47