Barplot





Welcome to the barplot section of the R graph gallery. A barplot is used to display the relationship between a numeric and a categorical variable. This section also include stacked barplot and grouped barplot where two levels of grouping are shown.

Step by step - ggplot2 and geom_bar()

ggplot2 allows to build barplot thanks to the geom_bar() function. The examples below will guide you through the basics of this tool:







Base R and the barplot() function

Basic R can build quality barplots thanks to the barplot() function. Here is a list of examples guiding you through the most common customization you will need.







Interactive barplot

Interactivity is a great way to enhance your graphics, and the ggiraph package makes it very easy! The following graphic shows what an interactive bar chart can look like. Try hovering over it!

Code





Interactive mekko chart

A Mekko chart, also known as a Marimekko chart, is a two-dimensional stacked bar chart where both the height and width of each bar segment represent different data dimensions, making it useful for visualizing categorical data distributions and market share comparisons.

Code
🌐 From the web

The web is full of astonishing R charts made by awesome bloggers. The R graph gallery tries to display some of the best creations and explain how their source code works. If you want to display your work here, please drop me a word or even better, submit a Pull Request!

Related chart types


Barplot
Spider / Radar
Wordcloud
Parallel
Lollipop
Circular Barplot