horzBarChart | R Documentation |
Create a horizontal bar chart
horzBarChart( data, label, value, fill = "crimson", sort = "none", paddingWidth = 0.1, stroke = NULL, strokeWidth = 1, bgcol = "#CAD0D3", valueTicks = NULL, valueFontSize = 10, labelFontSize = 10, valueTitle = NULL, valueTitleFontSize = 14, labelTitle = NULL, labelTitleFontSize = 14, font = "Verdana, Geneva, Tahoma, sans-serif", title = NULL, titleFontSize = 20, opacity = 1, axisCol = "black", width = NULL, height = NULL )
data |
The data frame containing the variables to consider. |
label |
The categorical variable to consider. Will be plotted on the y-axis. |
value |
The numeric variable to consider. Will be plotted on the x-axis. |
fill |
The color of the bars. Defaults to 'crimson'. |
sort |
Optional. Takes the following arguments: 'none', 'ascending' or 'descending', default to 'none' |
paddingWidth |
The distance between each bar. The value goes from 0 to 0.99 included. Defaults to 0.1. |
stroke |
Optional. The color of the stroke of the bars. |
strokeWidth |
The width of the stroke of the bars. Defaults to 1 when the 'stroke' parameter is used. |
bgcol |
Optional. The color of the background, default to: '#CAD0D3' |
valueTicks |
Optional. the number of x-axis ticks to consider. |
valueFontSize |
The font size of the x-axis values. Defaults to 10. |
labelFontSize |
The font size of the y-axis labels. Defaults to 10. |
valueTitle |
Optional. The title of the x-axis. |
valueTitleFontSize |
The font size of the x-axis title if specified. Defaults to 14. |
labelTitle |
Optional. The title of the y-axis. |
labelTitleFontSize |
The font size of the y-axis title. Defaults to 14. |
font |
The font family of the text. Defaults to "Verdana, Geneva, Tahoma, sans-serif" |
title |
Optional. The title of the overall graphic. |
titleFontSize |
The font size of the overall graphic's title when specified. |
opacity |
The color opacity of the bars. Goes from 0 to 1. Defaults to 1. |
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 horizontal bar chart.
library(ggplot2) # needed for the mpg data frame library(dplyr) # needed for the data wrangling process mpg %>% group_by(manufacturer) %>% summarise(median_hwy = median(hwy)) %>% horzBarChart( label = "manufacturer", value = "median_hwy", sort = "ascending" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.