In this tutorial, we will learn how to reverse the order of legend keys in ggplot2. In ggplot2, when we color by a variable using color or fill argument in side aes(), we get a legend with keys showing which keys match which colors. Here we will show how to reverse the … [Read more...] about How to reverse legend key order in ggplot2
Uncategorized
How to Increase Legend Key Size in ggplot2
In this tutorial, we will learn how to increase the color legend's point (or legend key) size in ggplot2. Often when you make a plot with multiple groups and large number of data points, the legend key for the color variable are small and can be not legible in the plot. Here … [Read more...] about How to Increase Legend Key Size in ggplot2
Lollipop plot with ggplot extension ggalt
In this tutorial, we will learn how to make lollipop plot using ggalt, one of the ggplot2 extension packages. A lollipop plot is a great alternative for bar plot as the amount ink used to make the lollipop plot is much smaller. ggalt, R package developed by @hrbrmstr, has a … [Read more...] about Lollipop plot with ggplot extension ggalt
How to write a function make histograms with ggplot
In this tutorial, we will learn how to write a function to make a histograms using ggplot2 in R. Writing a function to create plots is useful, when you make a lot of plots, in this example, a lot of histograms. Thanks to the upcoming 2nd edition of R for Data Science by … [Read more...] about How to write a function make histograms with ggplot
How to Add Colors to Axis Tick Label in ggplot2
In this tutorial, we will learn how to add colors to axis tick labels in ggplot2. To add colors to axis labels we will use the R package "ggtext: Improved text rendering support for ggplot2" developed by Claus Wilke. Let us get started by loading the packages … [Read more...] about How to Add Colors to Axis Tick Label in ggplot2