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(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
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.
- renderers#
An explicit list of renderers to autorange against. If unset, defaults to all renderers on a plot.
- class DataRange1d(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
An auto-fitting range in a continuous scalar dimension.
By default, the
startandendof the range automatically assume min and max values of the data for associated renderers.- 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 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. Settingmin > maxwill result in aValueError.If you only want to constrain one end of the plot, you can set
minormaxtoNonee.g.DataRange1d(bounds=(None, 12))
- default_span#
A default width for the interval, in case
startis equal toend(if used with a log axis, default_span is in powers of 10).
- flipped#
Whether the range should be “flipped” from its normal direction when auto-ranging.
- follow#
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 thatstartalways corresponds to the minimum data value (or maximum, ifflippedisTrue).If set to
"end"then the range will adjust so thatendalways corresponds to the maximum data value (or minimum, ifflippedisTrue).If set to
None(default), then auto-ranging does not follow, and the range will encompass both the minimum and maximum data values.followcannot be used with bounds, and if set, bounds will be set toNone.
- follow_interval#
If
followis 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#
The level that the range is allowed to zoom out, expressed as the maximum visible interval. Note that
boundscan impose an implicit constraint on the maximum interval as well.
- min_interval#
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.
- only_visible#
If True, renderers that that are not visible will be excluded from automatic bounds computations.
- range_padding#
How much padding to add around the computed data bounds.
When
range_padding_unitsis set to"percent", the span of the range span is expanded to make the rangerange_paddingpercent larger.When
range_padding_unitsis set to"absolute", the start and end of the range span are extended by the amountrange_padding.
- range_padding_units#
Whether the
range_paddingshould be interpreted as a percentage, or as an absolute quantity. (default:"percent")
- class FactorRange(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
A Range of values for a categorical dimension.
In addition to supplying
factorsas a keyword argument to theFactorRangeinitializer, you may also instantiate with a sequence of positional arguments:FactorRange("foo", "bar") # equivalent to FactorRange(factors=["foo", "bar"])
Users will normally supply categorical values directly:
p.scatter(x=["foo", "bar"], ...)
BokehJS will create a mapping from
"foo"and"bar"to a numerical coordinate system called synthetic coordinates. In the simplest cases, factors are separated by a distance of 1.0 in synthetic coordinates, however the exact mapping from factors to synthetic coordinates is affected by the padding properties as well as whether the number of levels the factors have.Users typically do not need to worry about the details of this mapping, however it can be useful to fine tune positions by adding offsets. When supplying factors as coordinates or values, it is possible to add an offset in the synthetic coordinate space by adding a final number value to a factor tuple. For example:
p.scatter(x=[("foo", 0.3), ...], ...)
will position the first circle at an
xposition that is offset by adding 0.3 to the synthetic coordinate for"foo".- bounds#
The bounds (in synthetic coordinates) that the range is allowed to go to. Typically used to prevent the user from panning/zooming/etc away from the data.
Note
Synthetic coordinates are only computed in the browser, based on the factors and various padding properties. Some experimentation may be required to arrive at bounds suitable for specific situations.
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
FactorRange.
- end#
The end of the range, in synthetic coordinates.
Note
Synthetic coordinates are only computed in the browser, based on the factors and various padding properties. The value of
endwill only be available in situations where bidirectional communication is available (e.g. server, notebook).
- factor_padding#
How much padding to add in between all lowest-level factors. When
factor_paddingis non-zero, every factor in every group will have the padding value applied.
- factors#
A sequence of factors to define this categorical range.
Factors may have 1, 2, or 3 levels. For 1-level factors, each factor is simply a string. For example:
FactorRange(factors=["sales", "marketing", "engineering"])
defines a range with three simple factors that might represent different units of a business.
For 2- and 3- level factors, each factor is a tuple of strings:
FactorRange(factors=[ ["2016", "sales"], ["2016", "marketing"], ["2016", "engineering"], ["2017", "sales"], ["2017", "marketing"], ["2017", "engineering"], ])
defines a range with six 2-level factors that might represent the three business units, grouped by year.
Note that factors and sub-factors may only be strings.
- group_padding#
How much padding to add in between top-level groups of factors. This property only applies when the overall range factors have either two or three levels. For example, with:
FactorRange(factors=[["foo", "1"], ["foo", "2"], ["bar", "1"]])
The top level groups correspond to
"foo"and"bar", and the group padding will be applied between the factors["foo", "2"]and["bar", "1"]
- max_interval#
The level that the range is allowed to zoom out, expressed as the maximum visible interval in synthetic coordinates.. Note that
boundscan impose an implicit constraint on the maximum interval as well.The default “width” of a category is 1.0 in synthetic coordinates. However, the distance between factors is affected by the various padding properties and whether or not factors are grouped.
- min_interval#
The level that the range is allowed to zoom in, expressed as the minimum visible interval in synthetic coordinates. If set to
None(default), the minimum interval is not bounded.The default “width” of a category is 1.0 in synthetic coordinates. However, the distance between factors is affected by the various padding properties and whether or not factors are grouped.
- range_padding#
How much padding to add around the outside of computed range bounds.
When
range_padding_unitsis set to"percent", the span of the range span is expanded to make the rangerange_paddingpercent larger.When
range_padding_unitsis set to"absolute", the start and end of the range span are extended by the amountrange_padding.
- range_padding_units#
Whether the
range_paddingshould be interpreted as a percentage, or as an absolute quantity. (default:"percent")
- start#
The start of the range, in synthetic coordinates.
Note
Synthetic coordinates are only computed in the browser, based on the factors and various padding properties. The value of
startwill only be available in situations where bidirectional communication is available (e.g. server, notebook).
- subgroup_padding#
How much padding to add in between mid-level groups of factors. This property only applies when the overall factors have three levels. For example with:
FactorRange(factors=[ ['foo', 'A', '1'], ['foo', 'A', '2'], ['foo', 'A', '3'], ['foo', 'B', '2'], ['bar', 'A', '1'], ['bar', 'A', '2'] ])
This property dictates how much padding to add between the three factors in the [‘foo’, ‘A’] group, and between the two factors in the [bar]
- class Range(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
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.
- class Range1d(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
A fixed, closed range [start, end] in a continuous scalar dimension.
In addition to supplying
startandendkeyword arguments to theRange1dinitializer, you can also instantiate with the convenience syntax:Range(0, 10) # equivalent to Range(start=0, end=10)
- 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.
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 aValueError.By default, bounds are
Noneand 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
- max_interval#
The level that the range is allowed to zoom out, expressed as the maximum visible interval. Can be a
TimeDelta. Note thatboundscan impose an implicit constraint on the maximum interval as well.
- min_interval#
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 aTimeDelta.
- reset_end#
The end of the range to apply when resetting. If set to
Nonedefaults to theendvalue during initialization.
- reset_start#
The start of the range to apply after reset. If set to
Nonedefaults to thestartvalue during initialization.