Description Usage Arguments Aesthetics Cosmetic Tips Examples
View source: R/stat_marimekko.R
Plot two categorical variables as marimekko
1 2 |
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. |
xbucket, ybucket, fill. Fill argument needs to be assigned to ybucket., or some other column which is a one to one mapping of ybucket.
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()
)
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'
)}
|
Loading required package: ggplot2
Warning: Ignoring unknown aesthetics: weight
Warning: Ignoring unknown aesthetics: fill, weight
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.