Reputation: 1571
I want to plot something very simple and I use this code:
df_tra %>%
filter(Theta_param ==1 & Gamma_param==0.76,Int_dis=='Bench' ) %>%
ggplot(aes(x = Debt, y = Gini_tra , colour =Rho_param )) +
geom_line()
The Rho_param
has four main levels:
.$ Rho_param : Factor w/ 4 levels "0","0.23","1", "1.2"
My question is how I should modify the colour
option in the ggplot if I want to only take into account a subset of these levels. Say want to plot only for when Rho_param
is equal to 0
and 1
Upvotes: 1
Views: 1005
Reputation: 34
You can filter your data; when you want to input your data to ggplot function you can do the following:
Data[Data$Rho_param==0 & Data$Rho_param==1,]
By doing so, you will not plot any Rho_params other than 0s and 1s. So the full function can be :
ggplot(Data[Data$Rho_param=="0" & Data$Rho_param=="1",], aes(x = Debt, y = Gini_tra , colour =Rho_param )) + geom_line()
Upvotes: 1