Learn R Programming

d3po (version 1.0.3)

po_box: Boxplot

Description

Draw a boxplot.

Usage

po_box(d3po, ..., data = NULL, inherit_daes = TRUE)

Value

an 'htmlwidgets' object with the desired interactive plot

Arguments

d3po

Either the output of d3po() or d3po_proxy().

...

Aesthetics, see daes().

data

Any dataset to use for plot, overrides data passed to d3po().

inherit_daes

Whether to inherit aesthetics previous specified.

Examples

Run this code
if (interactive()) {
  trade_continent <- d3po::trade
  trade_continent <- aggregate(
    trade ~ reporter_continent + reporter,
    data = trade_continent,
    FUN = sum
  )

  # my_pal <- tintin::tintin_pal(option = "Destination Moon")(7)
  # [1] "#5EBEDC" "#628EA3" "#8CB9AA" "#9D946F" "#C06F54" "#E2BB36" "#EB7227"

  my_pal <- c("#5EBEDC", "#628EA3", "#8CB9AA", "#9D946F", "#C06F54", "#E2BB36", "#EB7227")

  names(my_pal) <- c(
    "Africa", "Antarctica", "Asia",
    "Europe", "North America", "Oceania", "South America"
  )

  d3po(trade_continent, width = 800, height = 600) %>%
    po_box(daes(
      x = reporter_continent, y = trade, color = my_pal,
      tooltip = reporter_continent
    )) %>%
    po_labels(
      x = "Continent",
      y = "Trade (USD billion)",
      title = "Trade Distribution by Reporter Continent"
    )
}

Run the code above in your browser using DataLab