Multiple category layers in ggplot - Need to update the legend with categories

Hi,

I am working with a water quality dataset that has many monitoring sites. I am trying to create a scatter plot where I can differentiate categories for those monitoring sites (multiple sites under one category). Each category being color coded and monitoring sites having unique shapes.

My Current Code is like this:
ggplot(mapping = aes(x = "VARIABLE X", y = "VARIABLE Y", shape = "MONITORING STATION"))+
geom_point (aes(color = "CATEGORY"))

Note: I even tried to use variations such as:
ggplot(mapping = aes(x = "VARIABLE X", y = "VARIABLE Y", shape = "MONITORING STATION", color = "CATEGORY"))+
geom_point ()
and
ggplot(mapping = aes(x = "VARIABLE X", y = "VARIABLE Y", color = "CATEGORY"))+
geom_point (aes(shape = "MONITORING STATION"))

.................................
My legend looks like this:
Monitoring Stations
1... (Shape 1)
2... (Shape 2)
3... (Shape 3)
4... (Shape 4)
5... (Shape 5)
6... (Shape 6)

Category
A... (Color Red)
B... (Color Blue)
C... (Color Green)

............................................
Where I want it to look like this:

Category A
-Monitoring Station 1 (Color Red and Shape 1)
-Monitoring Station 2 (Color Red and Shape 2)

Category B
-Monitoring Station 3 (Color Blue and Shape 3)
-Monitoring Station 4 (Color Blue and Shape 4)

Category C
-Monitoring Station 5 (Color Green and Shape 5)
-Monitoring Station 6 (Color Green and Shape 6)

Does anyone have experience breaking apart categories like this? Any help would be much appreciated!
Thanks,
Tony

1 Like

Hi @algarcia2 , remember put a reproducible example of data for better help you all the community.

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.