bokeh.models.ranges

Models for describing different kinds of ranges of values in different kinds of spaces (e.g., continuous or categorical) and with options for “auto sizing”.

class DataRange(**kwargs)[source]

Bases: bokeh.models.ranges.Range

A base class for all data range types.

Note

This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not useful to instantiate on its own.

names

property type: List ( String )

A list of names to query for. If set, only renderers that have a matching value for their name attribute will be used for autoranging.

renderers

property type: List ( Instance ( Renderer ) )

An explicit list of renderers to autorange against. If unset, defaults to all renderers on a plot.

JSON Prototype
{
  "callback": null,
  "id": "7815c31d-4a06-48d6-83be-565aa998b576",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "name": null,
  "names": [],
  "renderers": [],
  "subscribed_events": [],
  "tags": []
}
class DataRange1d(*args, **kwargs)[source]

Bases: bokeh.models.ranges.DataRange

An auto-fitting range in a continuous scalar dimension. The upper and lower bounds are set to the min and max of the data.

bounds

property type: MinMaxBounds

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 will be None, allowing your plot to pan/zoom as far as you want. If bounds are ‘auto’ they will be computed to be the same as the start and end of the DataRange1d.

Bounds are provided as a tuple of (min, max) so regardless of whether your range is increasing or decreasing, the first item should be the minimum value of the range and the second item should be the maximum. Setting min > max will result in a ValueError.

If you only want to constrain one end of the plot, you can set min or max to None e.g. DataRange1d(bounds=(None, 12))

default_span

property type: Float

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).

end

property type: Float

An explicitly supplied range end. If provided, will override automatically computed end value.

flipped

property type: Bool

Whether the range should be “flipped” from its normal direction when auto-ranging.

follow

property type: Enum ( StartEnd )

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 None (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 None.

follow_interval

property type: Float

If follow is set to "start" or "end" then the range will always be constrained to that:

abs(r.start - r.end) <= follow_interval

is maintained.

max_interval

property type: Float

The level that the range is allowed to zoom out, expressed as the maximum visible interval. Note that bounds can impose an implicit constraint on the maximum interval as well.

min_interval

property type: Float

The level that the range is allowed to zoom in, expressed as the minimum visible interval. If set to None (default), the minimum interval is not bound.

range_padding

property type: Float

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

property type: Enum ( PaddingUnits )

Whether the range_padding should be interpreted as a percentage, or as an absolute quantity. (default: "percent")

start

property type: Float

An explicitly supplied range start. If provided, will override automatically computed start value.

JSON Prototype
{
  "bounds": null,
  "callback": null,
  "default_span": 2.0,
  "end": null,
  "flipped": false,
  "follow": null,
  "follow_interval": null,
  "id": "fa60c56e-08c4-4827-82e7-1df8829395b1",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "max_interval": null,
  "min_interval": null,
  "name": null,
  "names": [],
  "range_padding": 0.1,
  "range_padding_units": "percent",
  "renderers": [],
  "start": null,
  "subscribed_events": [],
  "tags": []
}
class FactorRange(*args, **kwargs)[source]

Bases: bokeh.models.ranges.Range

A range in a categorical dimension.

In addition to supplying factors keyword argument to the FactorRange initializer, you can also instantiate with the convenience syntax:

FactorRange("foo", "bar") # equivalent to FactorRange(factors=["foo", "bar"])

Note

FactorRange may be renamed to CategoricalRange in the future.

bounds

property type: Either ( Auto , List ( String ), List ( Int ) )

The bounds that the range is allowed to go to - typically used to prevent the user from panning/zooming/etc away from the data.

Unlike Range1d and DataRange1d, factors do not have an order and so a min and max cannot be proved in the same way. bounds accepts a list of factors, that constrain the displayed factors.

By default, bounds are None, allows unlimited panning or zooming.

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 list, then only the factors 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.

Examples:

Auto behavior:

x_range = FactorRange(
    factors=["apples", "dogs", "peaches", "bananas", "pigs"],
    bounds='auto'
)

The plot will display all the factors and you will not be able to
pan left of apples or right of pigs.

Constraining behavior:

x_range = FactorRange(
    factors=["apples", "dogs", "peaches", "bananas", "pigs"],
    bounds=["apples", "bananas", "peaches"]
)

Only the factors ``["apples", "peaches", "bananas"]`` (in that
order) will appear in the plot, and the plot will not pan left of
``"apples"`` or right of ``"bananas"``.
factors

property type: Either ( List ( String ), List ( Int ) )

A list of string or integer factors (categories) to comprise this categorical range.

max_interval

property type: Int

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

min_interval

property type: Int

The level that the range is allowed to zoom in, expressed as the minimum number of visible categories. If set to None (default), the minimum interval is not bound.

offset

property type: Float

An offset to the (synthetic) range (default: 0)

Note

The primary usage of this is to support compatibility and integration with other plotting systems, and will not generally of interest to most users.

JSON Prototype
{
  "bounds": null,
  "callback": null,
  "factors": [],
  "id": "ebcdf73a-92f8-4eb2-aad1-6212488b87fc",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "max_interval": null,
  "min_interval": null,
  "name": null,
  "offset": 0,
  "subscribed_events": [],
  "tags": []
}
class Range(**kwargs)[source]

Bases: bokeh.model.Model

A base class for all range types.

Note

This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not useful to instantiate on its own.

callback

property type: Instance ( Callback )

A callback to run in the browser whenever the range is updated.

JSON Prototype
{
  "callback": null,
  "id": "9a9d611b-20bf-4d44-9430-493f68bcf4d1",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "name": null,
  "subscribed_events": [],
  "tags": []
}
class Range1d(*args, **kwargs)[source]

Bases: bokeh.models.ranges.Range

A fixed, closed range [start, end] in a continuous scalar dimension.

In addition to supplying start and end keyword arguments to the Range1d initializer, you can also instantiate with the convenience syntax:

Range(0, 10) # equivalent to Range(start=0, end=10)
bounds

property type: MinMaxBounds

The bounds that the range is allowed to go to - typically used to prevent the user from panning/zooming/etc away from the data.

If set to 'auto', the bounds will be computed to the start and end of the Range.

Bounds are provided as a tuple of (min, max) so regardless of whether your range is increasing or decreasing, the first item should be the minimum value of the range and the second item should be the maximum. Setting min > max will result in a ValueError.

By default, bounds are None and your plot to pan/zoom as far as you want. If you only want to constrain one end of the plot, you can set min or max to None.

Examples:

Range1d(0, 1, bounds=’auto’) # Auto-bounded to 0 and 1 (Default behavior) Range1d(start=0, end=1, bounds=(0, None)) # Maximum is unbounded, minimum bounded to 0
end

property type: Either ( Float , Datetime , Int )

The end of the range.

max_interval

property type: Either ( Float , TimeDelta , Int )

The level that the range is allowed to zoom out, expressed as the maximum visible interval. Can be a timedelta. Note that bounds can impose an implicit constraint on the maximum interval as well.

min_interval

property type: Either ( Float , TimeDelta , Int )

The level that the range is allowed to zoom in, expressed as the minimum visible interval. If set to None (default), the minimum interval is not bound. Can be a timedelta.

start

property type: Either ( Float , Datetime , Int )

The start of the range.

JSON Prototype
{
  "bounds": null,
  "callback": null,
  "end": 1,
  "id": "021ca8e9-2022-47b2-a95c-15bd1401282e",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "max_interval": null,
  "min_interval": null,
  "name": null,
  "start": 0,
  "subscribed_events": [],
  "tags": []
}