Description Usage Arguments Details Examples
Function for plotting beautiful barcharts in ggplot
1 2 3 4 |
data |
data frame containing data for plotting |
y |
character string specifying column name in data that should be y variable |
x |
character string specifying column name in data that should be x variable |
na.rm |
a logical indicating whether NA values should be stripped before the computation proceeds |
title |
character string specifying chart title |
sub.title |
character string specifying chart sub title |
flip |
logical indicating whether barchart should be flipped or not |
y.title |
character string specifying y-axis title |
x.title |
character string specifying x-axis title |
decreasing |
logical indicating whether y values should be ordered and in which direction |
bar.colour.name |
character string indicating which bars to be coloured based on x names (see details) |
y.lim |
numeric vector with length two providing y-axis limits (min and max) |
y.breaks |
numeric vector specifying where ticks appear |
The option bar.colour.name allows for multiple bars based on x-axis names to get a different colour. If set to NULL all bars will have same default colour. Since ggplot2 version 2.2.0 this has changed as the ordering gets complicated when y values contain both positive and negative values. As a result bar colouring is only allowed decreasing is set to TRUE.
1 2 3 4 5 6 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.