Grouped barplot allows to show third categorical variable in the barplot. Sometimes, when we make grouped barplot using ggplot2, some of the bars would have much broader width sizes. We typically get bars with uneven widths in a grouped barplot when some of the groups don’t have data for all of its levels. In this… Continue reading How to Make Grouped Barplots with Same Bar Width
Author: datavizpyr
How To Fold Legend into Multiple Rows/Columns in ggplot2
When plotting with ggplot2 in R, long legends can sometimes overflow, look cluttered, or even get cut off when placed at the top or bottom of a chart. This is especially common when you have many categories (e.g., years or groups) and want the legend to be clearly readable. In this tutorial, we’ll learn how… Continue reading How To Fold Legend into Multiple Rows/Columns 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 difficult to understand as well.… Continue reading How to Add Labels Directly in ggplot2. Hint: Use Secondary Axis Trick
How To Customize Border in facet in ggplot2
Faceting in ggplot2 is one of the most powerful ways to create small multiples—a series of plots split by a grouping variable. With facet_wrap() and facet_grid(), you can easily compare distributions, trends, or relationships across categories. New to facets? Start here: How to make a facet plot using facet_wrap(). By default, each facet panel comes… Continue reading 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 by each Principal Component. In this post we… Continue reading How To Make PCA Plot with R
