Learn & Migrate

Your first ten minutes with CanvasXpress, plus translation guides from ggplot2 and Plotly — so you can reuse what you already know.

Your first ten minutes

The same chart in three languages, one engine. Pick your stack and paste.

JavaScript

<link rel="stylesheet" href="https://www.canvasxpress.org/dist/canvasXpress.css">
<script src="https://www.canvasxpress.org/dist/canvasXpress.min.js"></script>
<canvas id="chart" width="600" height="400"></canvas>
<script>
  new CanvasXpress("chart",
    { y: { vars: ["Sales"], smps: ["Q1","Q2","Q3","Q4"], data: [[10, 14, 9, 17]] } },
    { graphType: "Bar", title: "Quarterly Sales" });
</script>

R

install.packages("canvasXpress")
library(canvasXpress)

y <- matrix(c(10, 14, 9, 17), nrow = 1,
            dimnames = list("Sales", c("Q1","Q2","Q3","Q4")))
canvasXpress(data = y, graphType = "Bar", title = "Quarterly Sales")

Already have a ggplot? Wrap it: canvasXpress(ggplotObject) makes it interactive in one line — see the ggplot interface.

Python

pip install canvasxpress

from canvasxpress.canvas import CanvasXpress
from canvasxpress.data.keypair import CXDictData

chart = CanvasXpress(
    data=CXDictData({"y": {"vars": ["Sales"], "smps": ["Q1","Q2","Q3","Q4"],
                           "data": [[10, 14, 9, 17]]}}),
    config={"graphType": "Bar", "title": "Quarterly Sales"})

Next: open the examples gallery — every example is a live, editable spec you can copy.

Coming from ggplot2

CanvasXpress is built on the same grammar of graphics. Two paths: wrap an existing ggplot in R with canvasXpress(g), or author directly with cxplot, a ggplot2-style fluent builder in JavaScript. The concepts map almost one-to-one:

ggplot2CanvasXpress / cxplot
ggplot(df, aes(x, y))cx_plot(df, cx_aes(x, y)) — the data + aesthetic mapping
geom_point(), geom_line(), geom_bar()cx_geom_point(), cx_geom_line(), cx_geom_bar() — layers added with +
aes(color=, size=, shape=)same aesthetics — colour, size and shape scales resolve as in ggplot
facet_wrap(~g) / facet_grid(a~b)cx_facet_wrap(~g) / cx_facet_grid(a~b)
scale_*_manual/continuous()cx_scale_* equivalents (manual, continuous, brewer)
coord_flip(), coord_polar()cx_coord_flip(), polar coordinate support
theme_minimal(), theme_bw(), ggthemes19 built-in themes including the ggplot2 + ggthemes families
labs(title=, x=, y=)cx_labs(title=, x=, y=)
Static PNG/PDF outputInteractive by default — zoom, filter, tooltip, broadcast — and still exportable

See the cxplot interface for the full builder, or the ggplot interface for the one-line R wrapper.

Coming from Plotly

Both are declarative JSON figures with R/Python/JS APIs, so the mental model transfers. The main shift: Plotly builds a figure from traces; CanvasXpress maps a wide data matrix through a single grammar via graphType.

PlotlyCanvasXpress
A figure = list of traces + layoutOne data matrix (y/x/z) + one config
Trace type (scatter, bar, heatmap…)graphType (Scatter2D, Bar, Heatmap…)
mode: "markers"/"lines"graphType + scatterType / line options
layout.title, xaxis.titletitle, xAxisTitle
Group by splitting into multiple tracesGroup with one matrix + colorBy / annotations
fig.update_layout(...)keys in the config object
Faceting via subplotssegregateVariablesBy / segregateSamplesBy
Reproducibility handled in your codeBuilt in — the figure serializes to one portable spec (audit trail)

A fair, detailed feature comparison lives on the CanvasXpress vs. Plotly page — including where Plotly is the stronger choice.

Where to go next