Symlog scales¶
- detroit.scale_symlog() ScaleSymlog¶
- detroit.scale_symlog(range_vals: list[T]) ScaleSymlog
- detroit.scale_symlog(domain: list[int | float], range_vals: list[T]) ScaleSymlog
Builds a new continuous scale with the specified domain and range, the constant 1, the default interpolator and clamping disabled.
- Parameters:
domain (list[Number]) – Array of numbers
range_vals (list[Number]) – Array of values
- Returns:
Scale object
- Return type:
Examples
>>> scale = d3.scale_symlog([0, 100], [0, 960]) >>> scale = scale.set_constant(2) >>> steps = 10 >>> scale(0) 0.0 >>> scale(0.5) 54.48303899306232 >>> for x in range(steps + 1): ... x = 2 * x / steps ... x = 10 ** x ... print(x, scale(x)) ... ... 1.0 98.9989231832065 1.5848931924611136 142.48806851481947 2.51188643150958 198.64193111140278 3.9810717055349722 267.46722288814453 6.309573444801933 347.7495648320975 10.0 437.47847720986016 15.848931924611133 534.4195868305859 25.118864315095795 636.548856160817 39.810717055349734 742.2519630838442 63.09573444801933 850.343754278314
- class detroit.scale.symlog.ScaleSymlog(c: int | float = 1)¶
A bi-symmetric log transformation for wide-range data by Webber for details. Unlike a log scale, a symlog scale domain can include zero.
- Parameters:
c (Number) – Symlog constant value
- __call__(x: int | float | datetime) T¶
Given a value from the domain, returns the corresponding value from the range.
- Parameters:
x (int | float) – Input value
- Returns:
Corresponding value from the range
- Return type:
T
- invert(y: T) int | float¶
Given a value from the range, returns the corresponding value from the domain. Inversion is useful for interaction, say to determine the data value corresponding to the position of the mouse.
- Parameters:
y (T) – Input value
- Returns:
Corresponding value from the domain
- Return type:
Number
- set_domain(domain)¶
Sets the scale’s domain to the specified array of numbers.
- Parameters:
domain (list[Number] | list[datetime]) – Domain
- Returns:
Itself
- Return type:
Transformer[T]
- set_range(range_vals)¶
Sets the scale’s range to the specified array of values
- Parameters:
range_vals (list[T]) – Range values
- Returns:
Itself
- Return type:
Transformer[T]
- set_range_round(range_vals: list[T]) Transformer¶
Sets the scale’s range to the specified array of values and sets scale’s interpolator to
interpolate_round.- Parameters:
range_vals (list[T]) – Range values
- Returns:
Itself
- Return type:
- set_constant(c: int | float) ScaleSymlog¶
Sets the symlog constant to the specified number and returns this scale.
- Parameters:
c (Number) – Constant value
- Returns:
Itself
- Return type:
- set_clamp(clamp: bool) Transformer¶
Enables or disables clamping.
- Parameters:
clamp (bool) – Clamp value
- Returns:
Itself
- Return type:
- set_interpolate(interpolate: Callable[[T, T], Callable[[float], T]]) Transformer[T]¶
Sets the scale’s range interpolator factory.
- Parameters:
interpolate (Callable[[T, T], Callable[[float], T]]) – Interpolate function
- Returns:
Itself
- Return type:
Transformer[T]
- set_unknown(unknown: Any) Transformer¶
Sets the output value of the scale for undefined or NaN input values.
- Parameters:
unknown (Any) – Unknown value
- Returns:
Itself
- Return type:
- ticks(count: int | None = None) list[int | float]¶
Returns approximately count representative values from the scale’s domain.
- Parameters:
count (int | None) – Count. If specified, the scale may return more or fewer values depending on the domain
- Returns:
Tick values are uniformly spaced, have human-readable values (such as multiples of powers of 10), and are guaranteed to be within the extent of the domain. Ticks are often used to display reference lines, or tick marks, in conjunction with the visualized data.
- Return type:
list[Number]
- tick_format(count: int | None = None, specifier: str | None = None) Callable[[int | float], str]¶
Returns a number format function suitable for displaying a tick value, automatically computing the appropriate precision based on the fixed interval between tick values. The specified count should have the same value as the count that is used to generate the tick values.
- Parameters:
count (int | None) – Count. It should have the same value as the count that is used to generate the tick values.
specifier (str | None) – Specifier
- Returns:
Tick format function
- Return type:
Callable[[Number], str]
- nice(count: int | None = None) LinearBase¶
Extends the domain so that it starts and ends on nice round values.
- Parameters:
count (int | None) – Count argument allows greater control over the step size used to extend the bounds, guaranteeing that the returned ticks will exactly cover the domain
- Returns:
Itself
- Return type: