stat_marimekko: Plot two categorical variables as marimekko

Description Usage Arguments Aesthetics Cosmetic Tips Examples

View source: R/stat_marimekko.R

Description

Plot two categorical variables as marimekko

Usage

1
2
stat_marimekko(mapping = NULL, data = NULL, show.legend = NA,
  inherit.aes = TRUE, na.rm = T, xlabelyposition = NULL, ...)

Arguments

mapping

mapping

data

data

show.legend

logical

inherit.aes

logical

na.rm

logical

xlabelyposition

position

...

other functions A marimekko plot, or a mosaic plot, visualises the co-occurrence of two categorical / ordinal variables. In a time series, it could be used to visualise the transitions from one state to another by considering each state to be a category and plotting current category vs. next category.

Aesthetics

xbucket, ybucket, fill. Fill argument needs to be assigned to ybucket., or some other column which is a one to one mapping of ybucket.

Cosmetic Tips

The minimalist look can be achieved by appending the following chunk of code to the output object: + xlab(NULL) + ylab(NULL) + scale_fill_continuous(low = 'green', high = 'red') + theme( axis.text = element_blank(), axis.ticks = element_blank(), legend.position = 'none', strip.background = element_blank(), # strip.text = element_blank(), # useful if only one year of data plot.background = element_blank(), panel.border = element_blank(), panel.background = element_blank(), panel.grid = element_blank(), panel.border = element_blank() )

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
{
library(ggplot2)
ggplot(
   data.frame(
      x1 = round(3 * runif(10000), 0),
      y1 = pmax(pmin(round(3 * rnorm(10000), 0), 3), -3),
      weight = 1:10000
   )
) +
   stat_marimekko(
      aes(
         xbucket = x1,
         ybucket = y1,
         fill = factor(y1),
         weight = weight
      ),
      xlabelyposition = 1.1,
      color = 'black'
   )}

Example output

Loading required package: ggplot2
Warning: Ignoring unknown aesthetics: weight
Warning: Ignoring unknown aesthetics: fill, weight

ggTimeSeries documentation built on Jan. 23, 2022, 5:07 p.m.