range {rbokeh}R Documentation

Update x and y axis range in a Bokeh figure

Description

Update x and y axis range in a Bokeh figure

Usage

x_range(fig, lims = NULL, min_interval = NULL, max_interval = NULL,
  bounds = NULL, flipped = FALSE, range_padding = 0.07,
  range_padding_units = "percent", default_span = NULL, follow = NULL,
  follow_interval = NULL, callback = NULL, clear = FALSE)

y_range(fig, lims = NULL, min_interval = NULL, max_interval = NULL,
  bounds = NULL, flipped = FALSE, range_padding = 0.07,
  range_padding_units = "percent", default_span = NULL, follow = NULL,
  follow_interval = NULL, callback = NULL, clear = FALSE)

Arguments

fig

Figure to modify.

lims

Either a vector (min, max) if the range is numeric, or a vector of values if the range is categorical. In the latter case, the order in which the values are supplied is how they will be arranged on the axis.

min_interval

The level that the range is allowed to zoom in. For numeric ranges, it is expressed as the minimum visible interval. For categorical ranges, it is expressed as the minimum number of visible categories. If set to NULL (default), the minimum interval is not bound.

max_interval

The level that the range is allowed to zoom out. For numeric ranges, it is expressed as the maximum visible interval. For categorical ranges, it is expressed as the maximum number of visible categories. Note that bounds can impose an implicit constraint on the maximum interval as well.

bounds

The bounds that the range is allowed to go to - typically used to prevent the user from panning/zooming/etc away from the data. By default, the bounds are NULL, allowing unlimited panning or zooming. For numeric ranges, if you only want to constrain one end of the plot, you can set one end to NA, e.g. c(NA, 12). For categorical ranges, if bounds='auto', bounds will be the same as factors and the plot will not be able to pan or zoom beyond the first and last factors. If you provide a vector of factor levels, then only the values that are in that list will be displayed on the plot and the plot will not pan or zoom outside the first and last items in the shortened factors list. Note the order of factors is the defining order for your plot. Values of bounds that are not in factors are acceptable and will simply have no impact on the plot.

flipped

For numeric ranges only. Whether the range should be "flipped" from its normal direction when auto-ranging (boolean).

range_padding

For numeric ranges only. How much padding to add around the computed data bounds. When range_padding_units is set to "percent", the span of the range span is expanded to make the range range_padding percent larger. When range_padding_units is set to "absolute", the start and end of the range span are extended by the amount range_padding.

range_padding_units

For numeric ranges only. Whether the range_padding should be interpreted as a percentage, or as an absolute quantity. One of "percent" or "absolute".

default_span

For numeric ranges only. A default width for the interval, in case start is equal to end (if used with a log axis, default_span is in powers of 10).

follow

For numeric ranges only. Configure the data to follow one or the other data extreme, with a maximum range size of follow_interval. If set to "start" then the range will adjust so that start always corresponds to the minimum data value (or maximum, if flipped is True). If set to "end" then the range will adjust so that end always corresponds to the maximum data value (or minimum, if flipped is True). If set to NULL (default), then auto-ranging does not follow, and the range will encompass both the minimum and maximum data values. follow cannot be used with bounds, and if set, bounds will be set to NULL.

follow_interval

For numeric ranges only. If follow is set to "start" or "end" then the range will always be constrained to that.

callback

A string JavaScript code to be run any time the axis range is updated.

clear

A logical indicating whether all non-specified parameters should be cleared out of any exising specification in the figure. This can be useful when modifying a previously-defined figure.

Examples

figure() %>%
  ly_points(sample(1:26), letters) %>%
  x_range(c(-5, 31), range_padding = 0)

figure() %>%
  ly_points(sample(1:26), letters) %>%
  x_range(flipped = TRUE)

figure() %>%
  ly_points(sample(1:26), letters) %>%
  y_range(rev(letters))

figure() %>%
  ly_points(sample(1:26), letters) %>%
  x_range(bounds = c(-5, 31))

figure() %>%
  ly_points(sample(1:26), letters) %>%
  x_range(min_interval = 10, max_interval = 40)

figure() %>%
  ly_points(sample(1:26), letters) %>%
  y_range(min_interval = 10, max_interval = 40)

figure() %>%
  ly_points(sample(1:26), letters) %>%
  x_range(c(-5, 31), follow = "start", follow_interval = 10)

figure() %>%
  ly_points(sample(1:26), letters) %>%
  x_range(callback = "console.log(this.attributes.start)")

[Package rbokeh version 0.6.3 Index]