Home » Howto & Style » R programming - ggplot2 legend- examples of how to add, remove, alter the legend

R programming - ggplot2 legend- examples of how to add, remove, alter the legend

Written By Data For Knowledge on Wednesday, Oct 26, 2022 | 04:15 AM

 
R programming ggplot2 legend- Add, remove, and perform some alterations to the legend of a ggplot2 diagram using theme(), and guide() with guide_legend() . ⏱️ Timestamps: 00:00 Intro - ggplot2 legend 00:15 Basic line diagram used throughout example 00:50 Add legend 02:00 Remove legend 02:55 Remove legend title 03:55 Move legend to top of diagram 04:48 Alterations to legend using guides() 05:55 guide_legend guidance online 06:12 Alter number of rows in legend 06:45 Alter legend title placement 08:05 Remove legend title (alternative) The video creating the line diagram can be found at https://youtu.be/OkSE7TE8s_I Online guidance relating to legends and ggplot2 which may be helpful: https://ggplot2.tidyverse.org/reference/theme.html https://ggplot2.tidyverse.org/reference/guide_legend.html 🔔 Like and subscribe to the channel for more R Programming tutorials! https://www.youtube.com/@DFK_data?sub_confirmation=1 💥 For more R programming tutorials check out the playlist: https://www.youtube.com/playlist?list=PL856L03J0TRzutyNPb5yD2glKnrcWKpFm 👉 Follow me on LinkedIn: www.linkedin.com/in/pauline-cairns-data #ggplot2 #rprogramming #data #datavisualisation #rstudio