Plot.margin = unit(c(1, 1, 0.5, 0.5), "lines"), complete = TRUE)įor simple applications working with colors is straightforward in ggplot2 but when you have more advanced needs it can be a challenge. Plot.title = element_text(size = rel(1.2)), Plot.background = element_rect(colour = "white"), Strip.background = element_rect(fill = "grey80", colour = NA), Panel.background = element_rect(fill = "grey90", colour = NA), Legend.title = element_text(size = rel(0.8), face = "bold", hjust = 0), Legend.text = element_text(size = rel(0.8)), Legend.key = element_rect(fill = "grey95", colour = "white"), Legend.background = element_rect(colour = NA), Strip.text = element_text(size = rel(0.8)),Īxis.ticks = element_line(colour = "grey50"), Text = element_text(family = base_family, face = "plain", colour = "black", size = base_size, hjust = 0.5, vjust = 0.5, angle = 0, lineheight = 0.9),Īxis.text = element_text(size = rel(0.8), colour = "grey50"), Rect = element_rect(fill = "white", colour = "black", size = 0.5, linetype = 1), Line = element_line(colour = "black", size = 0.5, linetype = 1, lineend = "butt"), theme_grayįunction (base_size = 12, base_family = "") Note that the rel() function change the sizes relative to the base_size. If you wanted to create your own custom theme, you could extract the code directly from the gray theme and modify. If you want to change the theme for an entire session you can use theme_set as in theme_set(theme_bw()). # 3659 chic 127 17.0 5.75 9.365 14.941 3659 winter 1997Ī default plot in ggplot2 g<-ggplot(nmmaps, aes(date, temp))+geom_point(color="firebrick")īack to table of contents Tip on creating a custom theme # city date death temp dewpoint pm10 o3 time season year You can also download the data we’re using in this post here. For more detail on this dataset, consult Roger Peng’s book Statistical Methods in Environmental Epidemiology with R. To make the plots manageable we’re limiting the data to Chicago and 1997-2000. We’re using data from the National Morbidity and Mortality Air Pollution Study (NMMAPS). Create interactive, online versions of your plots (easier than you think).Adding a linear fit ( stat_smooth(method="lm")).Specifying the formula ( stat_smooth(formula=)).Default – adding LOESS or GAM ( stat_smooth()).Create a tiled correlation plot ( geom_tile()).Alternatives to the box plot ( geom_jitter() and geom_violin()).Flip a plot on it’s side ( coord_flip()).Add text annotation in the top-right, top-left etc. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |