This demo shows the ability to easily integrate CanvasXpress with ggplot in R. There are similar demos for python.

Scatter2d Plot

Data: mpg dataset

This dataset contains a subset of the fuel economy data that the EPA makes available on https://fueleconomy.gov/. It contains only models which had a new release every year between 1999 and 2008 - this was used as a proxy for the popularity of the car.

head(mpg)
## # A tibble: 6 × 11
##   manufacturer model displ  year   cyl trans      drv     cty   hwy fl    class 
##   <chr>        <chr> <dbl> <int> <int> <chr>      <chr> <int> <int> <chr> <chr> 
## 1 audi         a4      1.8  1999     4 auto(l5)   f        18    29 p     compa…
## 2 audi         a4      1.8  1999     4 manual(m5) f        21    29 p     compa…
## 3 audi         a4      2    2008     4 manual(m6) f        20    31 p     compa…
## 4 audi         a4      2    2008     4 auto(av)   f        21    30 p     compa…
## 5 audi         a4      2.8  1999     6 auto(l5)   f        16    26 p     compa…
## 6 audi         a4      2.8  1999     6 manual(m5) f        18    26 p     compa…

Plot with ggplot

Compare displacement (displ) vs highway efficiency (hwy) and color the data by vehicle class (class). Store the ggplot object in a variable.

s = ggplot(mpg, aes(displ, hwy)) + geom_point(aes(color = class))
s

Plot with CanvasXpress

Use the ggplot object stored in the variable ‘s’ and plot with CanvasXpress

canvasXpress(s)

Demo

You may want to make this page somehow BIG for this demo!

  • Tooltips – Mouseover data points

  • Toolbar – Mouseover top of the plot

  • Funnel – Click the funnel icon in toolbar to explore data with table and filters

    1. Select the 4 wheel drive type and cylinders between 4 and 6

    2. Reset the filter and close the explorer (at the top of the filters widget)

  • Tools – Click the tools icon in toolbar to Customize the graph

    1. Go to the Meta section and drag cyl to the size container

    2. Go to the Legend and click the icon to locate it at the top-right

    3. Close the customizer

  • Camera – Click the camera icon in the toolbar to save the graph as a PNG

    1. Go to any CanvasXpress graph ( https://canvasxpress.org/examples/bar-1.html ).

    2. Open the file explorer in your computer and drag the saved image onto the CanvasXpress graph

    3. Wow – it is not just the image; it is the ACTUAL data

  • History – Click the history button in the toolbar to reproduce everything you did to the visualization

Boxplot

Plot with ggplot

Look at the distribution of the highway millage (hwy) in each of the vehicle classes (class)

b <- ggplot(mpg, aes(class, hwy)) + geom_boxplot() + geom_jitter()
b

Plot with CanvasXpress

Use the ggplot object stored in the variable ‘b’ and plot with CanvasXpress

canvasXpress(b)

Demo

  • Broadcast – Go to the Scatter 2D plot above

    1. Press ‘Shift’ and drag the mouse to select points in the vissualization (they should turn red)

    2. Go to the Boxplot visualization below and check out the selected data points!

A full-fledged data analytics app in every visualization with ZERO extra coding

Themes in ggplot

bw = ggplot(mpg, aes(displ, hwy)) + geom_point(aes(color = class)) + theme_bw()
bw

canvasXpress(bw)