Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading