Skip to contents
0.16.6 documentation

Complete canonical API text; task articles explain the workflows. Tutorials

Site guide · find your task

Renders a plot with ggsave() into a temporary PNG or SVG and opens a small static preview page in the configured IDE viewer or web browser. This is an export-size preview, not an interactive plot conversion; the original plot and its standard ggsave() workflow remain unchanged. ggchord inputs are rendered on a private copy, preserving their layout cache. See ggchord_layout_contract for the distinct preview/export/diagnostic results. Automatic height fitting does not resize an overwide legend. If decorations exceed the requested width, increase width or use, for example, guides(seq_colour = guide_ggchord_legend(nrow = 2)).

Usage

Code
view_ggchord(
  plot = ggplot2::last_plot(),
  width = 12.39,
  height = 9.71,
  units = c("in", "cm", "mm", "px"),
  device = c("png", "svg"),
  dpi = 144,
  bg = NULL,
  viewer = c("auto", "ide", "browser", "none")
)

Arguments

plot

A ggchord or ggplot object, default last_plot().

width

Positive output width. With no explicit dimensions, coord_chord() uses 12.39 inches while coord_circular() derives its width from the annotation envelope.

height

Positive output height. With no explicit dimensions, coord_chord() uses 9.71 inches while coord_circular() derives both dimensions. Use NULL to fit the sequence, labels and legends while preserving equal coordinate units. Explicit width/height values are always respected.

units

Output units: "in", "cm", "mm", or "px".

device

Preview device, "png" or "svg". SVG output requires the optional svglite package or a working base Cairo SVG device.

dpi

Positive raster resolution, default 144.

bg

Optional background colour passed to ggsave().

viewer

How to open the preview: "auto" prefers getOption("viewer") and falls back to a browser in interactive sessions; "ide", "browser", and "none" select an explicit destination. "none" is useful in scripts and tests.

Value

The normalized temporary image path, invisibly.

RStudio plot pane and export-size rendering

Label packing, guide sizing, and fitted limits use the active graphics device's physical dimensions. Printing p in a small or narrow RStudio Plots pane can therefore produce a substantially different layout from an export, and very small panes may not have enough room for all radial labels. Resize or Zoom the pane and print again for a larger direct preview. For size-sensitive chord plots, use view_ggchord() while composing, then save the final figure with ggsave() at an explicit width and height matching the intended output. Preview measurements restore the previously active graphics device.

Examples

Code
library(dplyr)
data(seq_data_example)
p <- ggchord(seq_data_example) +
  geom_seq()
if (interactive()) view_ggchord(p)