barmekko: Create a bar mekko plot.

Description Usage Arguments Value Examples

View source: R/barmekko.R

Description

A smarter bar chart.

Usage

1
barmekko(data, x, y, width, values = FALSE)

Arguments

data

A data frame.

x

A categorical variable defining the width categories.

y

A numeric variable defining the bar height.

width

A numeric variable defining the bar widths

values

A boolean indicating whether to show value labels in bars

Value

A bar mekko constructed with ggplot2.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(ggplot2)
df <- data.frame(
  region = c('Northeast', 'Southeast', 'Central', 'West'),
  sales = c(1200, 800, 450, 900),
  avg_margin = c(3.2, -1.4, 0.1, 2.1)
  )
barmekko(df, region, avg_margin, sales)
barmekko(df, region, avg_margin, sales) + labs(title = 'Margins by Region')
barmekko(df[order(-df$sales),], region, avg_margin, sales)
barmekko(df[order(-df$avg_margin),], region, avg_margin, sales)

Example output



mekko documentation built on May 2, 2019, 5:56 a.m.