| lt_dotplot | R Documentation |
Render each row's values across one or more columns as inline dots on a
shared horizontal scale: N columns give N dots per row, laid out by value. It
is lightweight like lt_errorbar() and lt_sparkline() – only the numbers
travel to the client and the SVG is drawn in the browser, so an interactive
table (lt_interactive()) draws only the rows on the current page.
lt_dotplot(
x,
columns,
limits = NULL,
color = FALSE,
labels = NULL,
stagger = FALSE,
into = NULL,
width = 160,
height = NULL,
hide = TRUE,
axis = TRUE
)
x |
An |
columns |
The value column(s): one dot is drawn per column, read left to
right across the row, all on a scale shared across the columns. The plot is
drawn in the first column's cells, or into |
limits |
Numeric |
color |
Series colors. |
labels |
Legend labels, one per series, used when colored. Defaults to the series' value-column names. |
stagger |
If |
into |
Optional name of a dedicated column to draw the plot into,
instead of the first series' value column. The series columns ( |
width, height |
Pixel size of each cell's SVG. |
hide |
If |
axis |
Draw a shared horizontal axis (a baseline with tick marks and
labels at "nice" round values) in the table footer under the plot column,
plus faint vertical gridlines inside each cell at the same tick positions
to help read the bars. |
Since the cell shows every named column, the column header defaults to all
their names joined by " / " (e.g. "Before / After"); override it with a
later lt_label() on that column.
x with the dot-plot column recorded.
d = data.frame(
group = c("A", "B", "C"), before = c(3, 5, 4), after = c(6, 7, 5)
)
# one dot per column, colored and keyed by a footer legend, with an axis
lt(d) |> lt_dotplot(~ before + after, color = TRUE)
# custom colors and labels
lt(d) |> lt_dotplot(
~ before + after, color = c("#999", "#1a9641"),
labels = c("Baseline", "Follow-up")
)
# draw into a dedicated column, keeping the value columns visible as text
lt(d) |> lt_dotplot(~ before + after, into = "plot", hide = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.