so I am super to new to R, and I have been searching for hours and cant find a way to make this type of scatter plot. I have a data base with 3 columns X, Y, and Z, and I would like to scatter plot Y vs X, but only if Z has an specific value. so my Z has 3 types of values(low, mid, high). I would like to make 3 different graphs one for each value of column Z. Thank you for your help !
            Asked
            
        
        
            Active
            
        
            Viewed 187 times
        
    1 Answers
2
            We can use a basic geom_point plot and specify the 'color' as 'Z' as well as make it to 3 plots with `facet_wrap
library(dplyr)
library(ggplot2)
ggplot(df1, aes(x = X, y = Y, color = Z)) + 
     geom_point() + 
     facet_wrap(~ Z)
Using a reproducible example with iris
data(iris)
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) + 
        geom_point() + 
        facet_wrap(~ Species)
 
    
    
        akrun
        
- 874,273
- 37
- 540
- 662
