Coder Social home page Coder Social logo

ggmosaic's Introduction

ggmosaic

CRAN Status CRAN RStudio mirror downloads R-CMD-check


Overview

ggmosaic was designed to create visualizations of categorical data and is capable of producing bar charts, stacked bar charts, mosaic plots, and double decker plots.

Installation

You can install ggmosaic from github with:

# install.packages("devtools")
devtools::install_github("haleyjeppson/ggmosaic")

Example

library(ggmosaic)
library(dplyr)
happy %>% 
  mutate(finrela = forcats::fct_recode(finrela,
    "far below     " = "far below average",
    "    below" = "below average",
    "average" = "average",
    "above    " = "above average", 
    "l\n   far above" = "far above average")) %>% 
  ggplot() +
  geom_mosaic(aes(x = product(finrela), fill=health), show.legend = FALSE) +
  theme_mosaic() +
  scale_fill_manual(values = c("#4575B4", "#ABD9E9", "#FEE090", "#F46D43"))

geom_mosaic: setting the aesthetics

In geom_mosaic(), the following aesthetics can be specified:

  • weight: select a weighting variable

  • x: select variables to add to formula

    • declared as x = product(var2, var1, ...)
  • alpha: add an alpha transparency to the selected variable

    • unless the variable is called in x, it will be added to the formula in the first position
  • fill: select a variable to be filled

    • unless the variable is called in x, it will be added to the formula in the first position after the optional alpha variable.
  • conds : select a variable to condition on

    • declared as conds = product(cond1, cond2, ...)

These values are then sent through repurposed productplots functions to create the desired formula: weight ~ alpha + fill + x | conds.

Version compatibility issues with ggplot2

Since the initial release of ggmosaic, ggplot2 has evolved considerably. And as ggplot2 continues to evolve, ggmosaic must continue to evolve alongside it. Although these changes affect the underlying code and not the general usage of ggmosaic, the general user may need to be aware of compatibility issues that can arise between versions. The table below summarizes the compatibility between versions.

ggmosaic ggplot2 Axis labels Tick marks
0.3.3 3.3.3 x x
0.3.0 3.3.0 x x
0.2.2 3.3.0 Default labels are okay, but must use
scale_*_productlist() to modify
No tick marks
0.2.2 3.2.0 Default labels okay, but must use
scale_*_productlist() to modify
x
0.2.0 3.2.0 Default labels are wrong, but can use
labs() to modify
x

ggmosaic's People

Contributors

cpsievert avatar earowang avatar gegznav avatar gregleleu avatar haleyjeppson avatar heike avatar rekyt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ggmosaic's Issues

Package doesn't work correctly if not attached

If I don't attach the package with library(ggmosaic) or similar, I get the following error (with included sessionInfo()):

data(fly, package = "ggmosaic")
ggplot2::ggplot(data = fly) +
  ggmosaic::geom_mosaic(ggplot2::aes(x = ggmosaic::product(RudeToRecline), fill=DoYouRecline))
#> Error: Discrete value supplied to continuous scale
sessionInfo()
#> R version 3.6.1 (2019-07-05)
#> Platform: x86_64-apple-darwin15.6.0 (64-bit)
#> Running under: macOS Mojave 10.14.5
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_NZ.UTF-8/en_NZ.UTF-8/en_NZ.UTF-8/C/en_NZ.UTF-8/en_NZ.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.2         plyr_1.8.4         pillar_1.4.2      
#>  [4] compiler_3.6.1     highr_0.8          ggmosaic_0.2.1    
#>  [7] tools_3.6.1        digest_0.6.20      viridisLite_0.3.0 
#> [10] jsonlite_1.6       evaluate_0.14      tibble_2.1.3      
#> [13] gtable_0.3.0       pkgconfig_2.0.2    rlang_0.4.0       
#> [16] yaml_2.2.0         xfun_0.8           dplyr_0.8.3       
#> [19] stringr_1.4.0      httr_1.4.1         knitr_1.23        
#> [22] htmlwidgets_1.3    grid_3.6.1         tidyselect_0.2.5  
#> [25] glue_1.3.1         data.table_1.12.2  R6_2.4.0          
#> [28] plotly_4.9.0       rmarkdown_1.14     ggplot2_3.2.0     
#> [31] purrr_0.3.2        tidyr_0.8.3        magrittr_1.5      
#> [34] productplots_0.1.1 scales_1.0.0       htmltools_0.3.6   
#> [37] assertthat_0.2.1   colorspace_1.4-1   stringi_1.4.3     
#> [40] lazyeval_0.2.2     munsell_0.5.0      crayon_1.3.4

Created on 2019-08-06 by the reprex package (v0.3.0)

Attaching the package gives the desired output as per the example:

library(ggmosaic)
#> Loading required package: ggplot2

data(fly, package = "ggmosaic")
ggplot2::ggplot(data = fly) +
  ggmosaic::geom_mosaic(ggplot2::aes(x = ggmosaic::product(RudeToRecline), fill=DoYouRecline))

Created on 2019-08-06 by the reprex package (v0.3.0)

Customizing the tooltip for a plotly version of a geom_mosaic plot

This query relates to customising the tooptip for a plotly version of a mosaic plot, derived using the ggplotly command.

Starting with the canonical example

library(ggmosaic)

p <- ggplot(data = fly) +
  geom_mosaic(aes(x = product(rude_to_recline), fill=do_you_recline)) +
  theme_mosaic()

and then using ggplotly from {plotly}

library(plotly)
ggplotly(p)

we can create an interactive version of the mosaic plot.
The question relates to the tooltip. What you see when you hover over each cell in the plot.

For the top left, the tool tip text will read as

always
no
Frequency: 124

Is there a way of customising the tooltip text?

Similar examples for Barcharts would be along the lines of the code below

p <- ggplot(data = fly) +
  geom_mosaic(aes(x = product(rude_to_recline), fill=do_you_recline,
    text=paste("\n Rude to Recline?:",rude_to_recline,"\nDo you recline?",do_you_recline")
   )) +
  theme_mosaic()

ggplotly(p, tooltip="text")

Using aes_string with ggmosaic

Hi,

I have compositional data:

compositional.df <- data.frame(group = c(rep("A",5),rep("B",5)),
                               fraction = c(rep(0.2,5),c(0.1,0.2,0.3,0.2,0.2)),
                               category = c(rep(paste("c",1:5,sep=""),2)))

compositional.df$group <- factor(compositional.df$group,levels = c("A","B"))
compositional.df$category <- factor(compositional.df$category,levels = paste("c",1:5,sep=""))

which I'm plotting with ggmosaic:
ggplot(data=compositional.df)+geom_mosaic(aes(weight=fraction,x=product(group),fill=category))

I was trying to use aes_string since in my real code the values of weight, x, and fill are variables:

plot.variables <- c(weight="fraction", x = "group", fill = "category")

trying:
ggplot(data=compositional.df)+geom_mosaic(aes_string(weight=plot.variables[1],x=product(plot.variables[2]),fill=plot.variables[3]))+theme_minimal()
or simply:
ggplot(data=compositional.df)+geom_mosaic(aes_string(weight="fraction",x=product("group"),fill="category"))+theme_minimal()

both fail with this error:
Error in FUN(X[[i]], ...) : Unknown input:productlist

Any idea if this can be done? In ggplot2 aes_string is the solution for this.

Thanks a lot

Feature request: residual-based shadings

For me, one main virtue of mosaic plots is the ability to view the pattern of residuals from a given loglinear model.
It would be important to include this feature in geom_mosaic()

Failure to Knit to PDF Document

Even a very simple RMarkdown document that knits to PDF fails to compile to a PDF. If I run a *.Rmd file with just the following contents:

---
title: "Test Mosaic Plot"
date: "2023-01-18"
output:
  pdf_document
---
library(ggmosaic)
ggplot(data = fly) +
  geom_mosaic(aes(x = product(rude_to_recline), fill=do_you_recline)) +
  theme_mosaic()

It generates the following error message:

! LaTeX Error: Unicode character ^^[ (U+001B)
               not set up for use with LaTeX.

Error: LaTeX failed to compile Initial-Data-Review-TEST.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See Initial-Data-Review-TEST.log for more info.
Execution halted

No Problem with ggplot2 graphics

I know that knitting, LaTeX rendering, and PDF output are all prone to hidden conflicts, but I have no trouble generating PDF output of other ggplot2 graphics.

The Set Up

RStudio 2022.12.0+353 "Elsbeth Geranium" Release (7d165dcfc1b6d300eb247738db2c7076234f6ef0, 2022-12-03) for Windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2022.12.0+353 Chrome/102.0.5005.167 Electron/19.1.3 Safari/537.36

R version 4.2.2 (2022-10-31 ucrt) -- "Innocent and Trusting"

knitr version 1.41
markdown Vesion 1.4
tinytex version 0.43

data not recognized as data.frame

Hello. Sorry to bother you. I'm having issues implementing the library. I tried the example from the documentation but I get the error:

Error in alpha(data$fill, data$alpha) :
Data must either be a data frame or a matrix

Thanks for putting this library out there, I would really like to use it. This is my script:

library(ggplot2)
library(ggmosaic)
library(NHANES)

df.1 <- data.frame(NHANES, stringsAsFactors = F)

ggplot(data = df.1) +
  geom_mosaic(aes(weight = Weight, x = product(SleepHrsNight), fill=factor(SleepHrsNight)), na.rm=TRUE) +
  labs(x="Hours of sleep a night ", title='f(SleepHrsNight)') + guides(fill=guide_legend(title = "SleepHrsNight", reverse = TRUE))

What am I missing?

Calculating difference in conditional probabilities

Will you be incorporating a function to show the differences of conditional probabilities that is displayed visually in a mosaic plot?
If not, do you know any packages that produce the differences of conditional probabilities?

Issue using geom_mosaic

Hi I tried to create a mosaic plot using geom_mosaic. And this is the error I got
Warning message:
unite_() was deprecated in tidyr 1.2.0.
i Please use unite() instead.
i The deprecated feature was likely used in the ggmosaic package.
Please report the issue at https://github.com/haleyjeppson/ggmosaic.
This warning is displayed once every 8 hours.
Call lifecycle::last_lifecycle_warnings() to see where this warning was generated.
It looks like tidyr made some changes to their functions and it is affecting some of the functions in the ggmosaic package. I would be so grateful if you could look into this and make changes, I love using your package to create pretty plots.

outline color does not appear in legend

When you plot a geom_mosaic and specify an outline color with the color argument, the outline does not show up on the legend. Trying to force it using override.aes doesn't seem to work either.

library(ggmosaic)
ggplot(data = fly) + 
  geom_mosaic(aes(x = product(RudeToRecline), fill = DoYouRecline), color = "black")
# no black outline on legend
last_plot() + guides(fill = guide_legend(override.aes = list(color = "black")))
# still no black outline on legend

Axis labels no longer showing up

I'm wondering if ggplot2 3.3 has broken something. I now can't get axis labels (i.e., tick marks and tick mark labels) to appear, with or without scale_?_productlist:

library(ggplot2) ## version 3.3.0
ibrary(ggmosaic)  ## version 0.2.2
ggplot(data = titanic) + geom_mosaic(aes(x = product(Class), fill = Survived))

prodplot

No level names on the axes

A great package!
Do you know why I don't get the level names on the x nor y axes when I'm done the example from README?

ggplot (date = titanic) +
   geom_mosaic(aes(x = product(gender), fill=survived)) 

My session info

R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.3

other attached packages:
[1] forcats_0.5.0    patchwork_1.0.1  ggmosaic_0.3.0   ggplot2_3.3.2   
[5] DALEX_1.3.0      kableExtra_1.1.0

fill aesthetic shouldn't appear in x-axis labels

The variable used for the fill color shows up in labels on the x-axis. I'm not sure if it is ever desirable for that to happen, but here's an example where it isn't.

I thought it would be useful to show a confusion matrix using a mosaic plot. Here's a reproducible example.

library(dplyr)
library(ggplot2)
library(ggmosaic)

# Some sample data
set.seed(19790801)
actual <- iris$Species
predictions <- sample(iris$Species)

confusion <- table(actual, predictions) %>% 
  as.data.frame() %>% 
  mutate(
    is_correct = ifelse(
      actual == predictions, 
      "Correct prediction", 
      "Incorrect prediction"
    )
  )

ggplot(confusion) +
  geom_mosaic(
    aes(
      weight = Freq, 
      x = product(actual, predictions), 
      fill = is_correct
    )
  ) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

I expected the x-axis labels to be levels ofactual (setosa/versicolor/virginica), but they are actually combinations of is_correct (Correct prediction/Incorrect prediction) and predictions (setosa/versicolor/virginica).

  • Is this a bug?
  • Did I just specify the aesthetics incorrectly?
  • Is it possible to not show fill aesthetic values in x-axis labels?

Can't change axis labels with `labs`

Axis labels can't be changed with labs in 0.2.2. Reprexes below are from #41 (comment). I separately verified that the issue also occurs with ggplot2 3.2.1, so I presume it arises from changes in ggmosaic.

Leaving ggplot2 constant at 3.3.0 I tried to make the reprexes as systematic as possible

ggmosaic = 0.2.0 from CRAN labels YES, tick marks NO

library(ggplot2)
library(ggmosaic)
packageDescription("ggmosaic")$Version
#> [1] "0.2.0"
packageDescription("ggplot2")$Version
#> [1] "3.3.0"

data(Titanic)
titanic <- as.data.frame(Titanic)
titanic$Survived <- factor(titanic$Survived, 
                           levels = c("Yes", "No"))

ggplot(data = titanic) +
  geom_mosaic(aes(weight = Freq, x = product(Class), fill = Survived)) +
# good practice: use the 'dependent' variable (or most important variable)
# as fill variable
  labs(x = "Passenger class", 
       y = "Survived sinking",
       title = "Survival rate by passenger class")

Created on 2020-03-24 by the reprex package (v0.3.0)

ggmosaic = 0.2.2 from GitHub master labels NO, tick marks NO

library(ggplot2)
library(ggmosaic)
packageDescription("ggmosaic")$Version
#> [1] "0.2.2"
packageDescription("ggplot2")$Version
#> [1] "3.3.0"

data(Titanic)
titanic <- as.data.frame(Titanic)
titanic$Survived <- factor(titanic$Survived, 
                           levels = c("Yes", "No"))

ggplot(data = titanic) +
  geom_mosaic(aes(weight = Freq, x = product(Class), fill = Survived)) +
# good practice: use the 'dependent' variable (or most important variable)
# as fill variable
  labs(x = "Passenger class", 
       y = "Survived sinking",
       title = "Survival rate by passenger class")

Created on 2020-03-24 by the reprex package (v0.3.0)

ggmosaic = 0.2.2-hotfix from GitHub _ x and y labels NO, tick marks YES_

library(ggplot2)
library(ggmosaic)
# devtools::install_github('rmcd1024/ggmosaic', ref="ggplot_3.3.0-scales/fix")
packageDescription("ggmosaic")$Version
#> [1] "0.2.2"
packageDescription("ggmosaic")$RemoteRef
#> [1] "ggplot_3.3.0-scales/fix"
packageDescription("ggplot2")$Version
#> [1] "3.3.0"

data(Titanic)
titanic <- as.data.frame(Titanic)
titanic$Survived <- factor(titanic$Survived, 
                           levels = c("Yes", "No"))

ggplot(data = titanic) +
  geom_mosaic(aes(weight = Freq, x = product(Class), fill = Survived)) +
# good practice: use the 'dependent' variable (or most important variable)
# as fill variable
  labs(x = "Passenger class", 
       y = "Survived sinking",
       title = "Survival rate by passenger class")

Created on 2020-03-24 by the reprex package (v0.3.0)

Originally posted by @ibecav in #41 (comment)

Plotting using pre-computed contingency table

Is it possible to use ggmosaic with a contingence table data frame e.g.

library(ggmosaic)                                              
#> Loading required package: ggplot2
df <- as.data.frame(table(fly$DoYouRecline, fly$RudeToRecline))
df                                                             
#>                   Var1                Var2 Freq
#> 1               Always      Yes, very rude    3
#> 2              Usually      Yes, very rude    3
#> 3  About half the time      Yes, very rude    0
#> 4      Once in a while      Yes, very rude   11
#> 5                Never      Yes, very rude   54
#> 6               Always  Yes, somewhat rude    9
#> 7              Usually  Yes, somewhat rude   27
#> 8  About half the time  Yes, somewhat rude   35
#> 9      Once in a while  Yes, somewhat rude  129
#> 10               Never  Yes, somewhat rude   81
#> 11              Always No, not rude at all  124
#> 12             Usually No, not rude at all  145
#> 13 About half the time No, not rude at all   82
#> 14     Once in a while No, not rude at all  116
#> 15               Never No, not rude at all   35

If dev version of a dependency is required, put in "Remotes:"

I'm about to file an issue re: the as_tibble.list method exported here. It is causing problems in other packages, namely readxl (tidyverse/readxl#482).

But in my attempt to install this and get clear demo of the problem, I discovered ggmosaic requires the dev version of ggplot2. I suggest that you list ggplot2 in the "Remotes:" section of DESCRIPTION during this stage of development. This practice makes it easier for others to install ggmosaic via devtools::install_github().

usethis::use_dev_package() can make the necessary change to DESCRIPTION.

Error using the ] symbol in the labels

Hello

I'm using your new package ggmosaic to draw mosaic plots with ggplot2.

I have an error "Computation failed in stat_mosaic()" for just one of the variable from the dataset that I use. The problem seems located around the content of the variable, and more precisely around the treatment of ] because it works when I replace it by another symbol like ).

A simple example :

# Parameters
library(ggplot2)
library(ggmosaic)
set.separators(c(":", ";", "|")) # cf. ggmosaic documentation

# Plot OK
ggplot(data = df) +
  geom_mosaic(aes(weight = 1, x = product(TheGroup, TheRange), fill = TheGroup), na.rm = TRUE) +
  theme(axis.text.x = element_text(angle = 0, hjust = .1)) +
  labs(x = "TheRange", y = "TheGroup")

# Plot NOK
ggplot(data = df) +
  geom_mosaic(aes(weight = 1, x = product(TheRange, TheGroup), fill = TheRange), na.rm = TRUE) +
  theme(axis.text.x = element_text(angle = 0, hjust = .1)) +
  labs(x = "TheGroup", y = "TheRange")

And the subset of my data frame with the variable :

df <- structure(list(TheRange = structure(c(1L, 1L, 2L, 1L, 1L, 1L, 
                                            1L, 2L, 3L, 3L, 2L, 3L, 1L, 3L, 1L, 2L, 3L, 2L, 1L, 2L, 3L, 2L, 
                                            1L, 2L, 2L, 3L, 1L, 3L, 2L, 3L, 2L, 3L, 3L, 3L, 1L, 3L, 1L, 2L, 
                                            1L, 3L, 3L, 1L, 3L),
                     .Label = c("(0,30]", "(30,50]", "(50,100]"), class = "factor"),
                     TheGroup = c("Groupe 2", "Groupe 1", "Groupe 2", 
                                 "Groupe 1", "Groupe 1", "Groupe 2", "Groupe 1", "Groupe 2", "Groupe 2", 
                                 "Groupe 2", "Groupe 2", "Groupe 1", "Groupe 2", "Groupe 2", "Groupe 2", 
                                 "Groupe 2", "Groupe 1", "Groupe 2", "Groupe 1", "Groupe 2", "Groupe 1", 
                                 "Groupe 1", "Groupe 1", "Groupe 2", "Groupe 1", "Groupe 1", "Groupe 1", 
                                 "Groupe 2", "Groupe 1", "Groupe 1", "Groupe 2", "Groupe 2", "Groupe 2", 
                                 "Groupe 2", "Groupe 2", "Groupe 2", "Groupe 2", "Groupe 2", "Groupe 2", 
                                 "Groupe 2", "Groupe 2", "Groupe 2", "Groupe 2")),
                     .Names = c("TheRange", "TheGroup"),
                row.names = c(1L, 2L, 3L, 4L, 5L, 14L, 15L, 16L, 
                                               17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 30L, 
                                               31L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 41L, 42L, 43L, 44L, 46L, 
                                               47L, 49L, 50L, 51L, 52L, 53L, 54L, 55L, 56L),
                class = "data.frame")

A different offset for x and y

Let start with this example provided with the package:

data(Titanic)
titanic <- as.data.frame(Titanic)
titanic$Survived <- factor(titanic$Survived, levels=c("Yes", "No"))


ggplot(data=titanic) +
  geom_mosaic(aes(weight=Freq, x=product(Class), fill=Survived))

I would like to have a 0 offset for Y axis while keeping a positive offset for X axis.

Right now, only one value can be given.

Question:

Hi!

First of all, thanks for your package. I have just found its exstence right now, when I was looking for "its" existence a couple of years ago in this question at SO: https://stackoverflow.com/questions/66736582/how-to-make-a-percent-stacked-barplot-of-interactions-with-ggplot

I have found I can get something similar to what I was asking by means of

ggplot(mtcars) + geom_mosaic(aes(x = product(am, vs), fill = am))+ geom_mosaic_text(aes(x = product(am, vs), 
                       label = after_stat(round(100*.wt/sum(.wt),2))))

image

But then I ask again my question. Is it possible to get the four areas in such plot stacked in one column, so, for example, x would relate to am and y or fill would relate to the interactions with vs?

Thanks!

Failure with variables created on the fly

In contrast to ggplot2, it seems that ggmosaic does not support variables created on the fly:

library(tidyverse)
library(ggmosaic)

# OK: fill = cyl
ggplot(datasets::mtcars) +
  geom_mosaic(aes(x = product(gear), fill = cyl)) +
  scale_fill_discrete()

# FAILURE: fill = factor(cyl)
ggplot(datasets::mtcars) +
  geom_mosaic(aes(x = product(gear), fill = factor(cyl))) +
  scale_fill_discrete()
#> Warning: Computation failed in `stat_mosaic()`:
#> undefined columns selected

# FAILURE: fill = log(cyl)
ggplot(datasets::mtcars) +
  geom_mosaic(aes(x = product(gear), fill = log(cyl))) +
  scale_fill_discrete()
#> Warning: Computation failed in `stat_mosaic()`:
#> undefined columns selected

# OK: log is pre-computed
datasets::mtcars %>% 
  mutate(log_cyl = log(cyl)) %>% 
  ggplot() +
  geom_mosaic(aes(x = product(gear), fill = log_cyl)) +
  scale_fill_discrete()

Created on 2021-12-23 by the reprex package (v2.0.1)

Could ggmosaic support this kind of functionality? Or at least a more specific error message be issued to indicate what is the real issue?

CRAN update

Hi,

Wondering if the new changes will be pushed to CRAN any time soon. The CRAN version seems to still be at 2.0.0 from 2018. I'm hoping to upgrade my packages as well. Thank you.

"Error in is.finite(x) : default method not implemented for type 'list'"

When I use the example, error message shows: "Error in is.finite(x) : default method not implemented for type 'list'"

dim(matriz)
[1] 29 15
dim (rasgos)
[1] 15 4

data=data.frame()

for ( i in 1:ncol(rasgos))

{

x = rasgos[,i]

for (k in 1:nrow(matriz))

{

wt = matriz[k, ]

P29<- CWV(x,wt)

data[k, i]<-P29

}

}

Error in is.finite(x/wt) : default method not implemented for type 'list'

I am running R - 3.3.2 on Windows.

packageVersion("ggplot2")
[1] ‘3.0.0’
packageVersion("ggmosaic")
[1] ‘0.2.0’

Pleasee help!

Unless tibble is unloaded, dev version breaks (some) standard ggplot2 plots

Running 2.2.1.900 of ggplot2 and 0.1.2.900 of ggmosaic breaks some ggplot2 plots that rely on operations on factors (e.g. geom_tile(aes(fill = success)), where success is a factor).

Unloading tibble (which requires unloading ggmosaic, ggplot2, and all of tidyverse dependencies) with unloadNamespace is the only way to restore functionality. Unloading everything but tibble does not. Loading tibble on its own does not break things.

Installing cutting-edge version of tibble doesn't help; the problem occurs with the latest stable CRAN version as well. This report is generated from a Mac with packrat, but I continue to encounter it on x64 Windows 7 without packrat.

Reprex to follow.

> devtools::session_info()
Session info ----------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.1 (2017-06-30)
 system   x86_64, darwin16.6.0        
 ui       RStudio (1.0.153)           
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/New_York            
 date     2017-08-11                  

Packages --------------------------------------------------------------------------------
 package      * version    date       source                                
 assertthat     0.2.0      2017-04-11 CRAN (R 3.4.1)                        
 backports      1.1.0      2017-05-22 CRAN (R 3.4.1)                        
 base         * 3.4.1      2017-07-07 local                                 
 base64enc      0.1-3      2015-07-28 CRAN (R 3.4.1)                        
 bindr          0.1        2016-11-13 CRAN (R 3.4.1)                        
 bindrcpp     * 0.2        2017-06-17 CRAN (R 3.4.1)                        
 broom        * 0.4.2      2017-02-13 CRAN (R 3.4.1)                        
 car          * 2.1-5      2017-07-04 CRAN (R 3.4.1)                        
 cellranger     1.1.0      2016-07-27 CRAN (R 3.4.1)                        
 colorspace     1.3-2      2016-12-14 CRAN (R 3.4.1)                        
 compiler       3.4.1      2017-07-07 local                                 
 cowplot      * 0.8.0      2017-07-30 CRAN (R 3.4.1)                        
 data.table     1.10.4     2017-02-01 CRAN (R 3.4.1)                        
 datasets     * 3.4.1      2017-07-07 local                                 
 devtools       1.13.3     2017-08-02 CRAN (R 3.4.1)                        
 digest         0.6.12     2017-01-27 CRAN (R 3.4.1)                        
 dplyr        * 0.7.2      2017-07-20 CRAN (R 3.4.1)                        
 evaluate       0.10.1     2017-06-24 CRAN (R 3.4.1)                        
 forcats      * 0.2.0      2017-01-23 CRAN (R 3.4.1)                        
 foreign        0.8-69     2017-06-22 CRAN (R 3.4.1)                        
 gdata          2.18.0     2017-06-06 CRAN (R 3.4.1)                        
 ggmosaic     * 0.1.2.9000 2017-08-11 Github (haleyjeppson/ggmosaic@cf32577)
 ggplot2      * 2.2.1.9000 2017-08-11 Github (tidyverse/ggplot2@53a22cd)    
 glue           1.1.1      2017-06-21 CRAN (R 3.4.1)                        
 gmodels        2.16.2     2015-07-22 CRAN (R 3.4.1)                        
 graphics     * 3.4.1      2017-07-07 local                                 
 grDevices    * 3.4.1      2017-07-07 local                                 
 grid           3.4.1      2017-07-07 local                                 
 gtable         0.2.0      2016-02-26 CRAN (R 3.4.1)                        
 gtools         3.5.0      2015-05-29 CRAN (R 3.4.1)                        
 haven          1.1.0      2017-07-09 CRAN (R 3.4.1)                        
 highr          0.6        2016-05-09 CRAN (R 3.4.1)                        
 hms            0.3        2016-11-22 CRAN (R 3.4.1)                        
 htmltools      0.3.6      2017-04-28 CRAN (R 3.4.1)                        
 htmlwidgets    0.9        2017-07-10 CRAN (R 3.4.1)                        
 httr           1.2.1      2016-07-03 CRAN (R 3.4.1)                        
 jsonlite       1.5        2017-06-01 CRAN (R 3.4.1)                        
 kableExtra   * 0.4.0      2017-08-06 CRAN (R 3.4.1)                        
 knitr          1.16       2017-05-18 CRAN (R 3.4.1)                        
 labeling       0.3        2014-08-23 CRAN (R 3.4.1)                        
 lattice        0.20-35    2017-03-25 CRAN (R 3.4.1)                        
 lazyeval       0.2.0      2016-06-12 CRAN (R 3.4.1)                        
 lme4           1.1-13     2017-04-19 CRAN (R 3.4.1)                        
 lubridate      1.6.0      2016-09-13 CRAN (R 3.4.1)                        
 magrittr       1.5        2014-11-22 CRAN (R 3.4.1)                        
 MASS           7.3-47     2017-02-26 CRAN (R 3.4.1)                        
 Matrix         1.2-10     2017-05-03 CRAN (R 3.4.1)                        
 MatrixModels   0.4-1      2015-08-22 CRAN (R 3.4.1)                        
 memoise        1.1.0      2017-04-21 CRAN (R 3.4.1)                        
 methods      * 3.4.1      2017-07-07 local                                 
 mgcv           1.8-17     2017-02-08 CRAN (R 3.4.1)                        
 minqa          1.2.4      2014-10-09 CRAN (R 3.4.1)                        
 mnormt         1.5-5      2016-10-15 CRAN (R 3.4.1)                        
 modelr         0.1.0      2016-08-31 CRAN (R 3.4.1)                        
 munsell        0.4.3      2016-02-13 CRAN (R 3.4.1)                        
 nlme           3.1-131    2017-02-06 CRAN (R 3.4.1)                        
 nloptr       * 1.0.4      2014-08-04 CRAN (R 3.4.1)                        
 nnet           7.3-12     2016-02-02 CRAN (R 3.4.1)                        
 packrat        0.4.8-1    2016-09-07 CRAN (R 3.4.1)                        
 papeR        * 1.0-2      2017-02-16 CRAN (R 3.4.1)                        
 parallel       3.4.1      2017-07-07 local                                 
 pbkrtest       0.4-7      2017-03-15 CRAN (R 3.4.1)                        
 pkgconfig      2.0.1      2017-03-21 CRAN (R 3.4.1)                        
 plotly         4.7.1      2017-07-29 CRAN (R 3.4.1)                        
 plyr           1.8.4      2016-06-08 CRAN (R 3.4.1)                        
 productplots * 0.1.1      2016-07-02 CRAN (R 3.4.1)                        
 psych          1.7.5      2017-05-03 CRAN (R 3.4.1)                        
 purrr        * 0.2.3      2017-08-02 cran (@0.2.3)                         
 quantreg       5.33       2017-04-18 CRAN (R 3.4.1)                        
 R6             2.2.2      2017-06-17 CRAN (R 3.4.1)                        
 Rcpp           0.12.12    2017-07-15 CRAN (R 3.4.1)                        
 readr        * 1.1.1      2017-05-16 CRAN (R 3.4.1)                        
 readxl         1.0.0      2017-04-18 CRAN (R 3.4.1)                        
 reshape2       1.4.2      2016-10-22 CRAN (R 3.4.1)                        
 rlang          0.1.2      2017-08-09 cran (@0.1.2)                         
 rmarkdown      1.6        2017-06-15 CRAN (R 3.4.1)                        
 rprojroot      1.2        2017-01-16 CRAN (R 3.4.1)                        
 rvest          0.3.2      2016-06-17 CRAN (R 3.4.1)                        
 scales         0.4.1.9002 2017-08-11 Github (hadley/scales@9834874)        
 SparseM        1.77       2017-04-23 CRAN (R 3.4.1)                        
 splines        3.4.1      2017-07-07 local                                 
 stats        * 3.4.1      2017-07-07 local                                 
 stringi        1.1.5      2017-04-07 CRAN (R 3.4.1)                        
 stringr      * 1.2.0      2017-02-18 CRAN (R 3.4.1)                        
 tibble       * 1.3.3.9001 2017-08-11 Github (tidyverse/tibble@cd6337e)
     (but also tibble       * 1.3.3      2017-05-28 Github (cran/tibble@ad03076))
 tidyr        * 0.6.3      2017-05-15 CRAN (R 3.4.1)                        
 tidyverse    * 1.1.1      2017-01-27 CRAN (R 3.4.1)                        
 tools          3.4.1      2017-07-07 local                                 
 utils        * 3.4.1      2017-07-07 local                                 
 viridisLite    0.2.0      2017-03-24 CRAN (R 3.4.1)                        
 withr          2.0.0      2017-08-11 Github (jimhester/withr@190d293)      
 xml2           1.1.1      2017-01-24 CRAN (R 3.4.1)                        
 xtable       * 1.8-2      2016-02-05 CRAN (R 3.4.1)                        
 yaml           2.1.14     2016-11-12 CRAN (R 3.4.1)  

Avoid exporting as_tibble.list

I have a bug report on readxl that I believe originates in the as_tibble.list() method exported here (tidyverse/readxl#482).

as_tibble.list <- function(x, ...) {
#cat("as.tibble.list \n")
# still need to check that we are not accidentally hijacking a real list vector
# this is why we got called:
if (length(x) == 0) {
return(getFromNamespace("as_tibble.list", asNamespace("tibble"))(x))
}
idx <- which(sapply(x, function(xx) "tbl_df" %in% class(xx)))
if (length(idx) == 0) {
return(getFromNamespace("as_tibble.list", asNamespace("tibble"))(x))
}
if (! any(sapply(x[idx], function(xx) "productlist" %in% class(xx[[1]])))) {
dx <- getFromNamespace("as_tibble.list", asNamespace("tibble"))(x)
return(dx)
}

Unfortunately, I can't reproduce the OP's issue because he did not provide his test.xlsx file. But the spreadsheet must have some combination of missing/duplicated columns that creates a list that is an edge case for your code intended to "not accidentally hijack a real list vector".

I don't understand this package well enough to know why you have as_tibble.list(). But I think it's not a good practice to export a method (a list method, in this case) that masks a method provided by the package that owns the generic (as_tibble() and the tibble package, in this case).

Can you create an S3 class for whatever list-y output you need special handling for (e.g. mosaic_list) and create an as_tibble() method for that instead (e.g. as_tibble.mosaic_list)?

need documentation for the fill variable

Would like to set the color of the blocks by the percentage of a third variable not included in the aes() statement. How can I do that?
ggplot(data = phd) + geom_mosaic(aes(x = product(V1, V2) ), na.rm=TRUE, fill=V3)

Error in scale_x_productlist(sec.axis = ggplot2::sec_axis(~. * :

Error in scale_x_productlist(position = "top", sec.axis = ggplot2::sec_axis(~. *  : 
  Secondary axes must be specified using 'sec_axis()'

The erros shows when I try to add a second axis using scale_x_productlist(sec.axis = ggplot2::sec_axis(... A reproducible example is available here.

Possibel fixing: The function scale_x_productlist has a contradictory logict test:

if (is.sec_axis(sec.axis)) stop("Secondary axes must be specified using 'sec_axis()'")

Shouldn't it have NOT in the condition? Otherwise the error message doesn't make sense!
if (!is.sec_axis(sec.axis)) stop("Secondary axes must be specified using 'sec_axis()'")

geom_mosaic's `alpha` clashes with psych's `alpha`

If you have psych loaded (which is now a tidyverse autoload, I believe, via broom), geom_mosaic throws this error:

Error in alpha(data$fill, data$alpha) : 
  Data must either be a data frame or a matrix

Unloading psych dependencies and then unloading psych makes it work, because of the alpha function.

Specifying scales::alpha() in your code should fix this?

draw_panel = function(data, panel_scales, coord) {
 #  cat("draw_panel in GeomMosaic\n")
# browser()
   if (all(is.na(data$colour)))
     data$colour <- scales::alpha(data$fill, data$alpha) # regard alpha in colour determination

Make "RudeTo" variables factor levels consistent

Hi and thanks for a great package!

It seems like there is some inconsistency in the fly dataset "RudeTo" variables factor levels:

levels(fly$RudeToBringBaby)
# [1] "No, not at all rude" "Yes, somewhat rude"  "Yes, very rude"     
levels(fly$RudeToRecline)
# [1] "Yes, very rude"      "Yes, somewhat rude"  "No, not rude at all"

Difference (1): the order is different --> might want to have them as ordered factors

Difference (2): the "No" level label is different, "No, not at all rude" vs. "No, not rude at all"

Why is (2) a problem?

Because it makes remedying (1) harder, in case you'd like two different mosaics, ordered the same. This will give you wrong result:

fly %>% count(RudeToRecline)
# A tibble: 4 x 2
  RudeToRecline           n
  <fct>               <int>
1 Yes, very rude         71
2 Yes, somewhat rude    281
3 No, not rude at all   502
4 NA                    186
fly2 <- fly %>% mutate(RudeToRecline = factor(RudeToRecline, levels = levels(RudeToBringBaby), ordered = TRUE))
fly2 %>% count(RudeToRecline)
# A tibble: 3 x 2
  RudeToRecline          n
  <ord>              <int>
1 Yes, somewhat rude   281
2 Yes, very rude        71
3 NA                   688

factor level with 0 counts does not show up correctly

There is no child crew members, but those tiles incorrectly shows up due to spill over of 3rd Class & child

> data(Titanic)
> a <- as.data.frame(Titanic)
> ggplot(data = a) + geom_mosaic(aes(x = product(Class), fill=Survived, weight=Freq)) + facet_grid(Age~Sex)
> 

screen shot 2019-02-13 at 5 10 31 pm

Categorial labels on y-axis

I'm so glad you're revamping productplots!

In the original productplots::prodplot function, the y-axis scale was categorical, not continuous, with breaks for each of the categories:

prodplot(data=happy, ~ sex + marital)

image

With ggmosaic::geom_mosaic, the y-axis is now continuous, ranging from 0–1. The only way to distinguish between categories along the y axis is to use a fill aesthetic, since there are no y-axis labels:

ggplot(data=happy) + geom_mosaic(aes(x=product(sex, marital), fill=sex))

image

It would be nice to be able to use category labels on the y-axis in place of the continuous scale. Is there an option in geom_mosaic() that I'm missing to enable this, or is there some way of manipulating scale_y_discrete() to do this? Or is there a way to incorporate this feature from prodplot?

Thanks!

FILL with other variable than x and y variables

Hello,

Thank you for this ggplot2 extension !

Mosaic plots are very useful in statistics to illustrate results of khi2 tests (show intensity of correlation between two modalities thanks to the value of residuals).

Here is for example with base R mosaicplot function :

library(tidyverse)
library(ggmosaic)
mosaicplot(happy$marital~ happy$sex, shade = TRUE, main = "Title")

rplot3

I tried to do the same with ggmosaic but I cannot find a way to do it :(

The main issue is that I cannot find a way to use the field "fill" with other variables than the x or y value without obtaining strange outputs... Below is an example with the "var_fill" categorical variable.

library(tidyverse)
library(ggmosaic)

happy2 <- happy %>%
  group_by(sex,marital) %>%
  summarise(count = n()) %>%
  ungroup() %>%
  mutate(var_fill= LETTERS[sample.int(3, 12, replace = TRUE)])

> head(happy2)
# A tibble: 6 x 4
     sex       marital count var_fill
  <fctr>        <fctr> <int>    <chr>
1   male       married 13343        B
2   male never married  5204        A
3   male      divorced  2354        C
4   male       widowed   904        A
5   male     separated   627        B
6   male          <NA>     7        C

ggplot(data=happy2) +
  geom_mosaic(aes(weight=count, x=product(sex, marital), fill=sex)) +
  scale_y_productlist()

rplot1

Strange output when using another "fill" variable (many colors in each box instead of lines with small lines)

ggplot(data=happy2) +
  geom_mosaic(aes(weight=count, x=product(sex, marital), fill=var_fill)) +
  scale_y_productlist()

rplot2

It would be great if someone could help me to find out how I could modify the "fill" legend so that I can use another variable related to the importance of the residuals. Or even better so that I can plot for each box (var_x * var_y) the values of the residuals or the khi2 test (numeric variable which could be modify with scale_fill_continuous).

Thank you for your help !

Add percentage scale on x-axis

Is it possible to add a percentage scale to the x-axis of my ggmosaic plot, which is shown below?

You can reproduce my figure with this code.

eu_footprint_mosaic
Besides that it would be great to have the region names on top of the figure.

Many thanks for your help and for the great package!

Request for easy way to label tiles

Mosaic plots are great way to inform about proportions within groups, but they give you now way to indicate the total sample size / subgroup sizes. It's impossible to use geom_mosaic with geom_text to label tiles. Would it be possible to create an easy way to add geom_text to plots with geom_mosaic? That could result in:

  1. labeling tiles (like here)
  2. presenting raw numbers behind plots (which is crucial in case you are visualizing populations of different sizes).

Conflict in prodplot when using dev versions of ggplot2 (3.0.0.9000) & ggmosaic (0.2.1)

I am running into the below error when trying to use the dev versions of these packages, which to my understanding should no longer be in conflict.

> library(ggmosaic)
Loading required package: ggplot2
> #> Loading required package: ggplot2
> ggplot(data = fly) +
+     geom_mosaic(aes(x = product(RudeToRecline), fill=DoYouRecline))
Error in as.vector(x, "character") : 
  cannot coerce type 'closure' to vector of type 'character'
In addition: Warning message:
Computation failed in `stat_mosaic()`:
`b` = l must be a symbol or a string, not a formula 
> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.19.so

locale:
 [1] LC_CTYPE=C                 LC_NUMERIC=C              
 [3] LC_TIME=C                  LC_COLLATE=C              
 [5] LC_MONETARY=C              LC_MESSAGES=C             
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] ggmosaic_0.2.1     ggplot2_3.0.0.9000

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.18       pillar_1.2.2       compiler_3.5.0    
 [4] git2r_0.21.0       plyr_1.8.4         bindr_0.1.1       
 [7] tools_3.5.0        digest_0.6.15      jsonlite_1.5      
[10] memoise_1.1.0      tibble_1.4.2       gtable_0.2.0      
[13] viridisLite_0.3.0  pkgconfig_2.0.1    rlang_0.2.99.0000 
[16] rstudioapi_0.7     curl_3.2           yaml_2.1.18       
[19] bindrcpp_0.2.2     withr_2.1.2        dplyr_0.7.4       
[22] httr_1.3.1         knitr_1.20         htmlwidgets_1.2   
[25] devtools_1.13.5    grid_3.5.0         glue_1.2.0        
[28] data.table_1.11.2  R6_2.2.2           plotly_4.7.1      
[31] purrr_0.2.4        tidyr_0.8.0        magrittr_1.5      
[34] scales_0.5.0       productplots_0.1.1 htmltools_0.3.6   
[37] assertthat_0.2.0   colorspace_1.3-2   lazyeval_0.2.1    
[40] munsell_0.4.3      crayon_1.3.4  

However, when I try to use the CRAN versions, this error seems to be resolved:

> library(ggmosaic)
Warning message:
package ‘ggmosaic’ was built under R version 3.5.1 
> #> Loading required package: ggplot2
> ggplot(data = fly) +
+     geom_mosaic(aes(x = product(RudeToRecline), fill=DoYouRecline))
> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggmosaic_0.2.0 ggplot2_3.0.0 

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.17       plotly_4.8.0       bindr_0.1.1        magrittr_1.5       tidyselect_0.2.4   munsell_0.5.0     
 [7] viridisLite_0.3.0  colorspace_1.3-2   R6_2.2.2           rlang_0.2.1        httr_1.3.1         plyr_1.8.4        
[13] dplyr_0.7.5        tools_3.5.0        grid_3.5.0         data.table_1.11.4  gtable_0.2.0       withr_2.1.2       
[19] htmltools_0.3.6    yaml_2.1.19        lazyeval_0.2.1     assertthat_0.2.0   digest_0.6.15      tibble_1.4.2      
[25] bindrcpp_0.2.2     tidyr_0.8.1        purrr_0.2.5        htmlwidgets_1.2    glue_1.2.0         compiler_3.5.0    
[31] pillar_1.2.3       productplots_0.1.1 scales_0.5.0       jsonlite_1.5       pkgconfig_2.0.1 

expand parameter to scale_?_productlist doesn't work

Seems like this parameter is ignored and the limits are automatically inflated to -0.05,1.05. See also discussion in #4.

Last example contains a workaround.

library(ggplot2)
library(ggmosaic)

data(Titanic)
titanic <- as.data.frame(Titanic)
titanic$Survived <- factor(titanic$Survived, levels=c("Yes", "No"))

# Base plot
ggplot(data=titanic) +
  geom_mosaic(aes(weight=Freq, x=product(Class), fill=Survived))

# expand doesn't work
ggplot(data=titanic) +
  geom_mosaic(aes(weight=Freq, x=product(Class), fill=Survived)) +
  scale_x_productlist(expand = c(0,0))

# limits censors data
ggplot(data=titanic) +
  geom_mosaic(aes(weight=Freq, x=product(Class), fill=Survived)) +
  scale_x_productlist(limits = c(0.05,0.95))

# workaround that works
ggplot(data=titanic) +
  geom_mosaic(aes(weight=Freq, x=product(Class), fill=Survived)) +
  coord_cartesian(xlim=c(0.05/1.1, 1.05/1.1))

Pearson residuals

Is there a way to get Pearson residuals in the legend when using geom_mosaic() as they are used in vcd?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.