View source: R/lollipopChart.R
lollipopChart | R Documentation |
Create a lollipop chart
lollipopChart( data, x, y, sort = "none", bgcol = "white", xticks = NULL, yticks = NULL, xFontSize = 12, yFontSize = 12, font = "Verdana, Geneva, Tahoma, sans-serif", xtitle = NULL, xtitleFontSize = 14, ytitle = NULL, ytitleFontSize = 14, title = NULL, titleFontSize = 20, lineStroke = "maroon", lineStrokeWidth = 4, circleFill = "lime", circleStroke = "lime", circleStrokeWidth = 1, circleRadius = 10, axisCol = "black", width = NULL, height = NULL )
data |
The data frame containing the variables to consider. |
x |
The categorical variable to consider. Will be plotted on the x-axis. |
y |
The numeric variable to consider. Will be plotted on the y-axis. |
sort |
Whether to sort or not the vertical lines. Takes three values 'none' which is the default, 'ascending' or 'descending'. |
bgcol |
The background-color of the SVG output. Defaults to 'white'. |
xticks |
Optional. the number of x-axis ticks to consider. |
yticks |
Optional. The number of y-axis ticks to consider. |
xFontSize |
the font size of the x-axis labels. Defaults to 10. |
yFontSize |
the font size of the y-axis labels. Defaults to 10. |
font |
The font family to consider for the titles. Defaults to "Verdana, Geneva, Tahoma, sans-serif". |
xtitle |
Optional. The title of the x-axis. |
xtitleFontSize |
The font size of the x-axis title. Defaults to 16. |
ytitle |
Optional. The title of the y-axis. |
ytitleFontSize |
The font size of the y-axis title. Defaults to 16. |
title |
Optional. The title of the plot. |
titleFontSize |
The font size of the plot title. Defaults to 22. |
lineStroke |
The stroke color of the vertical lines. Defaults to 'maroon'. |
lineStrokeWidth |
The vertical lines stroke's width. Defaults to 4. |
circleFill |
The color of the circles. Defaults to 'lime'. |
circleStroke |
The color of the stroke surrounding the circle. Defaults to 'lime'. |
circleStrokeWidth |
The width of the circles' stroke. Defaults to 1. |
circleRadius |
The radius of the circles. Defaults to 10. |
axisCol |
the color of the x and y axis. It includes the ticks, the labels and titles. Defaults to 'black'. |
width |
Optional. The width of the SVG output. |
height |
Optional. The height of the SVG output. |
A SVG lollipop chart.
library(ggplot2) # needed for the mpg data frame library(dplyr) # needed for data wrangling mpg %>% group_by(drv) %>% summarise(median_cty = median(cty)) %>% lollipopChart( x = "drv", y = "median_cty", sort = "ascending", xtitle = "drv variable", ytitle = "median cty", title = "Median cty per drv" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.