mjs_add_legend: Adds a legend to a metricsgraphics chart

Description Usage Arguments Value Examples

View source: R/legend.r

Description

Adds a legend to a metricsgraphics chart

Usage

1
mjs_add_legend(mjs, legend, inline = FALSE)

Arguments

mjs

metricsgraphics plot object

legend

character vector of labels for the legend

inline

TRUE if you want line labes to the right of the chart vs in a legend block (experimental)

Value

metricsgraphics object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
set.seed(1492)
stocks <- data.frame(
  time = as.Date('2009-01-01') + 0:9,
  X = rnorm(10, 0, 1),
  Y = rnorm(10, 0, 2),
  Z = rnorm(10, 0, 4))

stocks %>%
  mjs_plot(x=time, y=X) %>%
  mjs_line() %>%
  mjs_add_line(Y) %>%
  mjs_add_line(Z) %>%
  mjs_axis_x(xax_format="date") %>%
  mjs_add_legend(legend=c("X", "Y", "Z"))

hrbrmstr/metricsgraphics documentation built on May 17, 2019, 5:10 p.m.