Need point size separate from aesthetics ggplot2

I feel like this should be really easy, but for some reason it's not working.

I want the size of my points to all be 1, independent of any aesthetics. When I put the size code in the aes function I get legend with a size of 1, which I don't want.

When I put the size command outside the aes function it doesn't change the size at all:

Here are my codes:

# size within aes()
bottle %>% 
  ggplot() +
  geom_point(aes(x=Temp, y=TP, color=Ship, size=1)) +
  theme_classic()

# size outside aes()
bottle %>% 
  ggplot() +
  geom_point(aes(x=Temp, y=TP, color=Ship), size=1) +
  theme_classic()

Here is a snippet of my data:

bottle <- structure(list(Station = c("STJ8", "STJ8", "STJ17", "STJ17", 
"EAS5", "EAS17", "EAS38", "EMP5"), Ship = c("Guardian", "Guardian", 
"Guardian", "Guardian", "LE2", "LE2", "LE2", "LE2"), Depth = c(5, 
5, 5, 5, 5, 5, 5, 5), TP = c(5.03, 5.03, 2.65, 2.65, 9.6, 9.77, 
9.81, 9.84), Temp = c(19.2, 21.5499, 19.352, 20.7097, 18.7557, 
18.3943, 18.2595, 18.5485)), class = c("grouped_df", "tbl_df", 
"tbl", "data.frame"), row.names = c(NA, -8L), groups = structure(list(
    Ship = c("Guardian", "LE2"), .rows = structure(list(1:4, 
        5:8), ptype = integer(0), class = c("vctrs_list_of", 
    "vctrs_vctr", "list"))), row.names = c(NA, -2L), class = c("tbl_df", 
"tbl", "data.frame"), .drop = TRUE))
> 

Thanks for your help on what is surely a very obvious and easy solution that I am failing to see.

I think you can handle this in two different ways. When size is outside the aes() function, try changing it to something larger than 1 that looks acceptable.

bottle %>% 
  ggplot() +
  geom_point(aes(x=Temp, y=TP, color=Ship), size = 4) +
  theme_classic()

If you leave size within the aes() function, you can remove the legend by specifying guide = 'none' within scale_size_continuous().

bottle %>% 
  ggplot() +
  geom_point(aes(x=Temp, y=TP, color=Ship, size = 1)) +
  scale_size_continuous(guide = 'none') +
  theme_classic()

1 Like

This topic was automatically closed 7 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.