Tal Itach
Tal Itach

Reputation: 41

how to combine 2 graphs - ggplot function in R

I want to combine these 2 graphs.

I want to see them in the same panel one on each other.

Plot 1 - shows the % of academics from the total job seekers.

Plot 2 - shows the % of woman seekers from the total job seekers. thanks for the help!

# PLOT 1
academic_plot <- ggplot(q1Subset, aes(MONTH, percAcademics)) +     
  geom_point(color="green") +                                    
  stat_smooth(method = "lm", formula = y ~ x, geom = "smooth") +   
  theme_minimal() + ggtitle("Percentage of Academic Seekers") + 
  ylab("Academic Seekers (%)") + 
academic_plot 

# PLOT 2
women_plot <- ggplot(q1Subset, aes(MONTH, percWomen)) +            
  geom_point(color="red") +
  stat_smooth(method = "lm", formula = y ~ x, geom = "smooth") +    
  theme_minimal() + ggtitle("Percentage of Women Seekers") +
  ylab("Women Seekers (%)")
women_plot

Upvotes: 1

Views: 123

Answers (1)

Rcheologist
Rcheologist

Reputation: 303

If you mean combining them on one grid, rawr's comment is helpful. However, if you mean combining them where you'd like to see a plot for the percentage of academic job seekers and highlighting the percentage of women, then I would suggest having one plot representing the percentage of academics from the total job seekers, and highlight that of women's with some colour. I cannot see your data, but I would assume there are percentages of men and women seekers. I would call it SeekersGender, and write the code below:

academic_plot <- ggplot(q1Subset, aes(MONTH, percAcademics)) +     
  geom_point(aes(colour = factor(SeekersGender))) +                                    
  stat_smooth(method = "lm", formula = y ~ x, geom = "smooth") +   
  theme_minimal() + ggtitle("Percentage of Academic Seekers") + 
  ylab("Academic Seekers (%)") + 
academic_plot 

This shall give each gender a certain colour and show a legend of the genders and their perspective colours, as well as highlight the women points of the academic seekers.

Upvotes: 1

Related Questions