This demo shows the ability to easily integrate CanvasXpress with ggplot in R. There are similar demos for python.
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…
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
Use the ggplot object stored in the variable ‘s’ and plot with CanvasXpress
canvasXpress(s)
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
Select the 4 wheel drive type and cylinders between 4 and 6
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
Go to the Meta section and drag cyl to the size container
Go to the Legend and click the icon to locate it at the top-right
Close the customizer
Camera – Click the camera icon in the toolbar to save the graph as a PNG
Go to any CanvasXpress graph ( https://canvasxpress.org/examples/bar-1.html ).
Open the file explorer in your computer and drag the saved image onto the CanvasXpress graph
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
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
Use the ggplot object stored in the variable ‘b’ and plot with CanvasXpress
canvasXpress(b)
Broadcast – Go to the Scatter 2D plot above
Press ‘Shift’ and drag the mouse to select points in the vissualization (they should turn red)
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
mn = ggplot(mpg, aes(displ, hwy)) + geom_point(aes(color = class)) + theme_minimal()
mn
canvasXpress(mn)