Learn R Programming

writexl (version 2.0.0)

xl_chart_legend: A chart's legend

Description

`xl_chart_legend()` moves, styles or removes the legend, and can leave individual series out of it.

Usage

xl_chart_legend(
  position = NULL,
  format = NULL,
  layout = NULL,
  delete_series = NULL
)

Value

An `xl_chart_legend` object.

Arguments

position

Where the legend sits: `"right"` (Excel's default), `"left"`, `"top"`, `"bottom"`, `"top_right"`, the `"overlay_*"` variants that let the legend sit over the plot, or `"none"` to remove it.

format

An [xl_format()] styling the legend text --- the [xl_font()] group only, since libxlsxwriter gives a legend a font and nothing else.

layout

Where to put the legend by hand, as `c(x, y)` or `c(x, y, width, height)` --- fractions of the chart, each above 0 and at most 1. Excel places it for you otherwise. `at` is a cell everywhere else in writexl, so a chart's own fractions are a `layout`.

delete_series

Series to leave out of the legend, by position: `2` drops the second series' entry while still plotting it. This is how a trendline or a helper series is kept out of the key.

See Also

[xl_chart]

Other images and charts: xl_chart(), xl_chart_axis(), xl_chart_error_bars(), xl_chart_labels(), xl_chart_marker(), xl_chart_series(), xl_chart_table(), xl_chart_trendline(), xl_chartsheet(), xl_image()

Examples

Run this code
xl_chart_legend(position = "bottom")
xl_chart_legend(position = "none")
xl_chart_legend(delete_series = 2)

Run the code above in your browser using DataLab