Place legends side by side


Is there a way to place these two legends side by side as opposed to on top of one another? I want this figure to have the legends Temperature and TP right next to each other.

And here is my code. Unfortunately it's not reproducible as the Lake Michigan outline is a shapefile.

tptemp <- ggplot() +
  geom_sf(data=lm, fill="white") +
  geom_sf(data=sfo, aes(color=Temp, size=TP)) +
  scale_color_gradient(low="blue", high="red") +
  theme(axis.text.x = element_blank(),  # remove x-axis text
        axis.text.y = element_blank(), # remove y-axis text
        axis.ticks = element_blank(),  # remove axis ticks
        axis.title.x = element_text(size=18), # remove x-axis labels
        axis.title.y = element_text(size=18), # remove y-axis labels
        panel.background = element_blank(), 
        panel.grid.major = element_blank(),  #remove major-grid labels
        panel.grid.minor = element_blank(),  #remove minor-grid labels
        plot.background = element_blank()) +
    location = "tl", which_north = "true",
    style = ggspatial::north_arrow_nautical(fill = c("grey40", "white"),
                                            line_col = "grey20"))  +
    location = "br",
    bar_cols = c("grey60", "white")) +
                      #aes(label = Station), size=3,
                      #force = 150,
                      #label.padding = 0.2) +
  labs(color = 'Temperature (°C)',
       size = bquote('TP µg'~L^-1),
       y=NULL) +

Can something be added on or altered to achieve what I want?

Thanks so much!

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.