Use your ggplot2 (and ggpubr) plots directly with canvasXpress

R
canvasXpress
ggplot2
ggpubr
visualization
You don’t have to rewrite your plots. Hand an existing ggplot object to canvasXpress() and get an interactive, reproducible version — pairwise significance brackets included.
Author

Isaac Neuhaus

Published

September 25, 2026

If you already build plots with ggplot2 or ggpubr, you don’t need to learn a new plotting API to make them interactive. canvasXpress accepts a ggplot object directly: pass it to canvasXpress() and it renders an interactive, reproducible version of the same figure — you keep your existing code.

Install

install.packages(c("canvasXpress", "ggpubr"))

Wrap a plot you already have

Here’s an ordinary ggpubr boxplot with pairwise comparisons (geom_pwc) — the significance brackets that show a test between each pair of groups. Build it exactly as you normally would:

library(ggplot2)
library(ggpubr)

g <- ggboxplot(iris, x = "Species", y = "Sepal.Width", fill = "Species") +
  geom_pwc(method = "t_test", label = "p.format")

Now make it interactive — one call, the same object:

library(canvasXpress)

canvasXpress(g)

That’s the whole idea: no re-specification. canvasXpress reads the ggplot object — its data, aesthetics, layers, scales and the geom_pwc brackets — and renders it. Hover the points, drag to zoom, or open the toolbar to filter and re-style, and the result serializes to one portable spec you can store and reproduce from R, Python or JavaScript.

What transfers

  • Geoms and layers — points, boxes, lines, and stats like geom_pwc / stat_compare_means.
  • Aesthetic mappings — x, y, fill, color, grouping.
  • Scales, labels and facets from the ggplot object.

When to reach for the native API instead

Wrapping a ggplot is ideal for reusing plots you already have. When you’re building a figure fresh — or want fine control over CanvasXpress-specific features (clustering, dendrograms, interactive annotations) — call canvasXpress() on your data directly with a graphType. See the other posts for that style.

Next