Description Usage Arguments Details Examples
Given a named vector or a data frame, this function will return a ggplot object that represents a waffle chart of the values. The individual values will be summed up and each that will be the total number of squares in the grid. You can perform appropriate value transformation ahead of time to get the desired waffle layout/effect.
1 2 3 4 |
parts |
named vector of values or a data frame to use for the chart |
rows |
number of rows of blocks |
keep |
keep factor levels (i.e. for consistent legends across waffle plots) |
xlab |
text for below the chart. Highly suggested this be used to give the "1 sq == xyz" relationship if it's not obvious |
title |
chart title |
colors |
exactly the number of colors as values in |
size |
width of the separator between blocks (defaults to |
flip |
flips x & y axes |
reverse |
reverses the order of the data |
equal |
by default, waffle uses |
pad |
how many blocks to right-pad the grid with |
use_glyph |
use specified FontAwesome glyph |
glyph_size |
size of the FontAwesome font |
legend_pos |
position of legend |
If a data frame is used, the first two columns should contain the desired names and the values, respectively.
If the vector is not named or only partially named, capital letters will be used instead.
It is highly suggested that you limit the number of elements to plot, just like you should if you ever got wasted and decided that a regular pie chart was a good thing to create and then decide to be totally evil and make one to pollute this beautiful world of ours.
Chart title and x-axis labels are optional, especially if you'll just be exporting to another program for use/display.
If you specify a string (vs FALSE
) to use_glyph
the function
will map the input to a FontAwesome glyph name and use that glyph for the
tile instead of a block (making it more like an isotype pictogram than a
waffle chart). You'll need to install FontAwesome and use
the extrafont
package (https://github.com/wch/extrafont
) to
be able to use the FontAwesome glyphs. Sizing is also up to the user since
fonts do not automatically scale with graphic resize.
Glyph idea inspired by Ruben C. Arslan (@_r_c_a)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.