Sometimes when we make a plot with a legend either on top or bottom, it may be too long. In this post, we will learn to fold the long legend into two or more rows (or columns) with ggplot2 in R. Example plot with long legend that needs to be wrapped into two rows We … [Read more...] about How To Fold Legend into Multiple Rows in ggplot2
How to Add Labels Directly in ggplot2. Hint: Use Secondary Axis Trick
Legends can be of great help to understand a plot. Typically, ggplot2 adds legend by default on right side of the plot based on the variable that we used to color or fill. However, as Cluas Wilke says in his fantastic book on Data Visualization, legends can make the plot … [Read more...] about How to Add Labels Directly in ggplot2. Hint: Use Secondary Axis Trick
How To Customize Border in facet in ggplot2
ggplot2's facet options are a great way make small multiples, i.e. multiple plots of the same type in a panel or grid. In this post, we will learn how to control the border line in a plot made with facet_wrap() function in ggplot2. First we will see how to remove the border … [Read more...] about How To Customize Border in facet in ggplot2
How To Make PCA Plot with R
Principal Component Analysis (PCA) is one of the commonly used methods used for unsupervised learning. Making plots using the results from PCA is one of the best ways understand the PCA results. Earlier, we saw how to make Scree plot that shows the percent of variation explained … [Read more...] about How To Make PCA Plot with R
Sinaplot vs Violin plot: Why Sinaplot is better than Violinplot
In this post, we will learn how to make Sinaplot in R and show why it is a better way visualize numerical data from multiple categories. In an earlier post, we discussed the benefits of making Violinplot than making a boxplot. This is mainly due to the fact that Boxplot relies … [Read more...] about Sinaplot vs Violin plot: Why Sinaplot is better than Violinplot