lollipop | R Documentation |
This function creates a lollipop chart from a (optionally named) numeric vector.
lollipop(x, names = NULL, ymin = 0, sticks = TRUE, col = "royalblue",
grid = TRUE, cex = 1, cex.axis = 1, las = 2, ...)
x |
a numeric vector. |
names |
a vector of the same length as 'x' with the names to be plotted below the lollipops. If this argument is left NULL and 'x' has names, then these will be used. |
ymin |
numeric value for the lower limit of the y axis. The default is zero. If set to NA, the minimum of 'x' will be used. |
sticks |
logical value indicating whether the sticks of the lollipops should be drawn. The default is TRUE. |
col |
colour for the lollipops. |
grid |
logical, whether or not to add a grid to the plot. The default is TRUE. |
cex |
numeric value indicating the size of the lollipops. Will be passed as 'cex' to 'points' and as 'lwd' to 'arrows' (the lines or lollipop sticks). |
cex.axis |
numeric value indicating the size of the x and y axis labels. |
las |
argument to pass to |
... |
additional arguments that can be used for the plot, e.g. 'main'. |
According to modern data viz recommendations, lollipop charts are generally a better alternative to bar charts, as they reduce the visual distortion caused by the length of the bars, making it easier to compare the values.
This function produces a lollipop chart of the values in 'x'.
A. Marcia Barbosa
barplot
lollipop(mtcars[,1], names = rownames(mtcars), las = 2, ylab = names(mtcars)[1],
cex.axis = 0.6, main = "Lollipop chart")
lollipop(mtcars[,1], names = rownames(mtcars), las = 2, ylab = names(mtcars)[1],
cex.axis = 0.6, main = "Lollipop chart", ymin = NA)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.