Initialise an horizon plot.

horizon(data, ..., utc = TRUE, military = TRUE, bands = 4L,
  mode = c("offset", "mirror"), normalize = FALSE, scale = 1L,
  positive_colors = c("white", "midnightBlue"),
  negative_colors = c("white", "crimson"), interpolation_curve = NULL,
  ruler = TRUE, zoom = FALSE, transition = FALSE,
  positive_colors_stops = NULL, negative_colors_stops = NULL,
  aggregation = NULL, extent = NULL, width = "100%",
  height = NULL, elementId = NULL)



A data.frame or tibble.


Attributes, specified using attrs.


Whether to use the local timezone (FALSE) or UTC (TRUE).


Whether to show time in 24h or 12h (am/pm) format.


Number of horizon bands to use.


Mode used to represent negative values. offset renders the negative values from the top of the chart downwards, while /codemirror represents them upwards as if they were positive values, albeit with a different color.


Whether to normalize all series Y axis to the same extent, in order to compare series in absolute terms. It defines the behavior of the dynamic calculation of the max Y, when extent is not explicitly set. If TRUE, the extent is calculated as the global maximum value of all the data points combined across all series. If FALSE, each series extent will be based on their own local maximum.


Set the y-axis scale exponent. Only values > 0 are supported. An exponent of 1 (default) represents a linear Y scale. A function (JS) receives the series ID as input and should return a numeric value. A number sets the same scale exponent for all the series.

positive_colors, negative_colors

Colors to use for the positive and negative value bands.


Interpolation curve function used to draw lines between points. Should be a d3 curve function. A falsy value sets linear interpolation (curveLinear).


Whether to show the ruler.


Whether to enable pointer-based zoom interactions on the chart, along the time (x-axis) dimension.


Duration (in milliseconds) of the transitions between data states.

positive_colors_stops, negative_colors_stops

Each stop represents an interpolation ratio and only values between ]0, 1[ (excluding) are permitted. The stops are used to interpolate the middle colors in *_colors and are only applicable if there are more than 2 colors. If the number of stops is less than number of middle colors, linear interpolation is used to populate the remaining stops. A value of NULL (default) results in complete linear interpolation.


A function (JS) to reduce multiple values to a single number, in case there is more than one y value per unique x and group (in attrs).


JavaScript function or number to set the y-axis maximum absolute value. By default (NULL), the max Y is calculated dynamically from the data. A function (JS) receives the series ID as input and should return a numeric value. A numeric sets the same extent for all the series.

width, height

Must be a valid CSS unit (like '100%', '400px', 'auto') or a number, which will be coerced to a string and have 'px' appended.


Id of element.


horizon(tsdata, attrs(x = dates, y = value, group = grp))