JavaScript Library

Include the CanvasXpress JavaScript library in the <head></head> of your web page.

<link rel="stylesheet" href="path-to-canvasXpress.css" type="text/css"/>
<script type="text/javascript" src="path-to-canvasXpress.min.js"></script>

Any code as decribed below should be placed in a <script></script> tag.

Plot basics

All cxplot plots begin with a call to var cxp = cxplot(), supplying a DOM target id to place the visualization, a default data and aesthethic mappings, specified by aes(). You can also supply an additional parameter with custom events. You then add layers, scales, coords and facets with cxp.

cxplot()

Create a new cxplot

aes()

Construct aesthetic mappings

Layers

Geoms

A layer combines data, aesthetic mapping, a geom (geometric object), a stat (statistical transformation), and a position adjustment. Typically, you will create layers using a geom_ function, overriding the default position and stat if needed.

geom_abline() geom_hline() geom_vline()

Reference lines: horizontal, vertical, and diagonal

geom_bar() geom_col() stat_count()

Bar charts

geom_bin_2d() stat_bin_2d()

Heatmap of 2d bin counts

geom_boxplot() stat_boxplot()

A box and whiskers plot (in the style of Tukey)

geom_contour() geom_contour_filled() stat_contour() stat_contour_filled()

2D contours of a 3D surface

geom_density() stat_density()

Smoothed density estimates

geom_density_2d() geom_density_2d_filled() stat_density_2d() stat_density_2d_filled()

Contours of a 2D density estimate

geom_dotplot()

Dot plot

geom_errorbarh()

Horizontal error bars

geom_hex() stat_bin_hex()

Hexagonal heatmap of 2d bin counts

geom_histogram() stat_bin()

Histograms and frequency polygons

geom_jitter()

Jittered points

geom_path() geom_line() geom_step()

Connect observations

geom_point()

Points

geom_qq_line() stat_qq_line() geom_qq() stat_qq()

A quantile-quantile plot

geom_quantile() stat_quantile()

Quantile regression

geom_ribbon() geom_area()

Ribbons and area plots

geom_rug()

Rug plots in the margins

geom_smooth() stat_smooth()

Smoothed conditional means

geom_text()

Text

geom_raster()

Rectangles

geom_violin() stat_ydensity()

Violin plot

Scales

Scales control the details of how data values are translated to visual properties. Override the default scales to tweak details like the axis labels or legend keys, or to use a completely different translation from data to aesthetic. labs() and lims() are convenient helpers for the most common adjustments to the labels and limits.

labs() xlab() ylab() ggtitle()

Modify axis, legend, and plot labels

xlim() ylim()

Set scale limits

Facetting

Facetting generates small multiples, each displaying a different subset of the data. Facets are an alternative to aesthetics for displaying additional discrete variables.

facet_wrap()

Wrap a 1d ribbon of panels into 2d

Themes

Themes control the display of all non-data elements of the plot.

theme()