A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://ultraplot.readthedocs.io/en/latest/api/ultraplot.colors.ContinuousColormap.html below:

ContinuousColormap — UltraPlot documentation

UltraPlot ContinuousColormap
class ContinuousColormap(*args, gamma=1, alpha=None, cyclic=False, **kwargs)[source]

Bases: LinearSegmentedColormap, _Colormap

Replacement for LinearSegmentedColormap.

Parameters:
  • segmentdata (dict-like) – Dictionary containing the keys 'red', 'green', 'blue', and (optionally) 'alpha'. The shorthands 'r', 'g', 'b', and 'a' are also acceptable. The key values can be callable functions that return channel values given a colormap index, or 3-column arrays indicating the coordinates and channel transitions. See matplotlib.colors.LinearSegmentedColormap for a detailed explanation.

  • name (str, default: '_no_name') – The colormap name. This can also be passed as the first positional string argument.

  • N (int, default: rc['image.lut'] = 256) – Number of points in the colormap lookup table.

  • gamma (float, optional) – Gamma scaling used for the x coordinates.

  • alpha (float, optional) – The opacity for the entire colormap. This overrides the input opacities.

  • cyclic (bool, optional) – Whether the colormap is cyclic. If True, this changes how the leftmost and rightmost color levels are selected, and extend can only be 'neither' (a warning will be issued otherwise).

Other Parameters:

**kwargs – Passed to matplotlib.colors.LinearSegmentedColormap.

Methods Summary

append(*args[, ratios, name, N])

Return the concatenation of this colormap with the input colormaps.

concatenate(*[, new_obj, message])

copy([name, segmentdata, N, alpha, gamma, ...])

Return a new colormap with relevant properties copied from this one if they were not provided as keyword arguments.

cut([cut, name, left, right])

Return a version of the colormap with the center "cut out".

from_file(path, *[, warn_on_failure])

Load colormap from a file.

from_list(*args, **kwargs)

Make a ContinuousColormap from a sequence of colors.

punched(*[, new_obj, message])

reversed([name])

Return a reversed copy of the colormap.

save([path, alpha])

Save the colormap data to a file.

set_alpha(alpha[, coords, ratios])

Set the opacity for the entire colormap or set up an opacity gradation.

set_cyclic(b)

Set whether this colormap is "cyclic".

shifted([shift, name])

Return a cyclicaly shifted version of the colormap.

to_discrete([samples, name])

Convert the ContinuousColormap to a DiscreteColormap by drawing samples from the colormap.

to_listed(*[, new_obj, message])

truncate([left, right, name])

Return a truncated version of the colormap.

truncated(*[, new_obj, message])

updated(*[, new_obj, message])

Methods Documentation

append(*args, ratios=None, name=None, N=None, **kwargs)[source]

Return the concatenation of this colormap with the input colormaps.

Parameters:
  • *args – Instances of ContinuousColormap.

  • ratios (sequence of float, optional) – Relative extent of each component colormap in the merged colormap. Length must equal len(args) + 1. For example, cmap1.append(cmap2, ratios=(2, 1)) generates a colormap with the left two-thrids containing colors from cmap1 and the right one-third containing colors from cmap2.

  • name (str, optional) – The colormap name. Default is to merge each name with underscores and prepend a leading underscore, for example _name1_name2.

  • N (int, optional) – The number of points in the colormap lookup table. Default is to sum the length of each lookup table.

Other Parameters:

**kwargs – Passed to ContinuousColormap.copy or PerceptualColormap.copy.

Returns:

ContinuousColormap – The colormap.

concatenate(*, new_obj=<function ContinuousColormap.append>, message="'concatenate' was deprecated in version 0.6.0 and may be removed in the next major release (version 2.0.0). Please use 'append' instead.", **kwargs)
copy(name=None, segmentdata=None, N=None, *, alpha=None, gamma=None, cyclic=None)[source]

Return a new colormap with relevant properties copied from this one if they were not provided as keyword arguments.

Parameters:
  • name (str, default: '_name_copy') – The new colormap name.

  • segmentdata, N, alpha, gamma, cyclic (optional) – See ContinuousColormap. If not provided, these are copied from the current colormap.

cut(cut=None, name=None, left=None, right=None, **kwargs)[source]

Return a version of the colormap with the center “cut out”. This is great for making the transition from “negative” to “positive” in a diverging colormap more distinct.

Parameters:
  • cut (float, optional) – The proportion to cut from the center of the colormap. For example, cut=0.1 cuts the central 10%, or cut=-0.1 fills the ctranl 10% of the colormap with the current central color (usually white).

  • name (str, default: '_name_copy') – The new colormap name.

  • left, right (float, default: 0, 1) – The colormap indices for the “leftmost” and “rightmost” colors. See truncate for details.

  • right (float, optional) – The colormap index for the new “rightmost” color. Must fall between

Other Parameters:

**kwargs – Passed to ContinuousColormap.copy or PerceptualColormap.copy.

Returns:

ContinuousColormap – The colormap.

classmethod from_file(path, *, warn_on_failure=False)[source]

Load colormap from a file.

Parameters:
  • path (path-like) – The file path. Valid file extensions are shown in the below table.

    Extension

    Description

    .json

    JSON database of the channel segment data.

    .hex

    Comma-delimited list of HEX strings.

    .rgb, .txt

    3-4 column table of channel values.

  • warn_on_failure (bool, optional) – If True, issue a warning when loading fails instead of raising an error.

classmethod from_list(*args, **kwargs)[source]

Make a ContinuousColormap from a sequence of colors.

Parameters:
  • colors (sequence of color-spec or tuple) – If a sequence of RGB[A] tuples or color strings, the colormap transitions evenly from colors[0] at the left-hand side to colors[-1] at the right-hand side.

    If a sequence of (float, color-spec) tuples, the float values are the coordinate of each transition and must range from 0 to 1. This can be used to divide the colormap range unevenly.

  • name (str, default: '_no_name') – The colormap name. This can also be passed as the first positional string argument.

  • ratios (sequence of float, optional) – Relative extents of each color transition. Must have length len(colors) - 1. Larger numbers indicate a slower transition, smaller numbers indicate a faster transition. For example, ('red', 'blue', 'green') with ratios=(2, 1) creates a colormap with the transition from red to blue taking twice as long as the transition from blue to green.

Other Parameters:

**kwargs – Passed to ContinuousColormap.

Returns:

ContinuousColormap – The colormap.

punched(*, new_obj=<function ContinuousColormap.cut>, message="'punched' was deprecated in version 0.6.0 and may be removed in the next major release (version 2.0.0). Please use 'cut' instead.", **kwargs)
reversed(name=None, **kwargs)[source]

Return a reversed copy of the colormap.

Parameters:

name (str, default: '_name_r') – The new colormap name.

Other Parameters:

**kwargs – Passed to ContinuousColormap.copy or PerceptualColormap.copy.

save(path=None, alpha=True)[source]

Save the colormap data to a file.

Parameters:
  • path (path-like, optional) – The output filename. If not provided, the colormap is saved in the cmaps subfolder in user_folder() under the filename name.json (where name is the colormap name). Valid extensions are shown in the below table.

    Extension

    Description

    .json

    JSON database of the channel segment data.

    .hex

    Comma-delimited list of HEX strings.

    .rgb, .txt

    3-4 column table of channel values.

  • alpha (bool, optional) – Whether to include an opacity column for .rgb and .txt files.

set_alpha(alpha, coords=None, ratios=None)[source]

Set the opacity for the entire colormap or set up an opacity gradation.

Parameters:
  • alpha (float or sequence of float) – If float, this is the opacity for the entire colormap. If sequence of float, the colormap traverses these opacity values.

  • coords (sequence of float, optional) – Colormap coordinates for the opacity values. The first and last coordinates must be 0 and 1. If alpha is not scalar, the default coordinates are np.linspace(0, 1, len(alpha)).

  • ratios (sequence of float, optional) – Relative extent of each opacity transition segment. Length should equal len(alpha) + 1. For example cmap.set_alpha((1, 1, 0), ratios=(2, 1)) creates a transtion from 100 percent to 0 percent opacity in the right third of the colormap.

set_cyclic(b)[source]

Set whether this colormap is “cyclic”. See ContinuousColormap for details.

shifted(shift=180, name=None, **kwargs)[source]

Return a cyclicaly shifted version of the colormap. If the colormap cyclic property is set to False a warning will be raised.

Parameters:
  • shift (float, default: 180) – The number of degrees to shift, out of 360 degrees.

  • name (str, default: '_name_s') – The new colormap name.

Other Parameters:

**kwargs – Passed to ContinuousColormap.copy or PerceptualColormap.copy.

to_discrete(samples=10, name=None, **kwargs)[source]

Convert the ContinuousColormap to a DiscreteColormap by drawing samples from the colormap.

Parameters:
  • samples (int or sequence of float, optional) – If integer, draw samples at the colormap coordinates np.linspace(0, 1, samples). If sequence of float, draw samples at the specified points.

  • name (str, default: '_name_copy') – The new colormap name.

Other Parameters:

**kwargs – Passed to DiscreteColormap.

to_listed(*, new_obj=<function ContinuousColormap.to_discrete>, message="'to_listed' was deprecated in version 0.8.0 and may be removed in the next major release (version 2.0.0). Please use 'to_discrete' instead.", **kwargs)
truncate(left=None, right=None, name=None, **kwargs)[source]

Return a truncated version of the colormap.

Parameters:
  • left (float, default: 0) – The colormap index for the new “leftmost” color. Must fall between 0 and 1. For example, left=0.1 cuts the leftmost 10% of the colors.

  • right (float, default: 1) – The colormap index for the new “rightmost” color. Must fall between 0 and 1. For example, right=0.9 cuts the leftmost 10% of the colors.

  • name (str, default: '_name_copy') – The new colormap name.

Other Parameters:

**kwargs – Passed to ContinuousColormap.copy or PerceptualColormap.copy.

truncated(*, new_obj=<function ContinuousColormap.truncate>, message="'truncated' was deprecated in version 0.6.0 and may be removed in the next major release (version 2.0.0). Please use 'truncate' instead.", **kwargs)
updated(*, new_obj=<function ContinuousColormap.copy>, message="'updated' was deprecated in version 0.6.0 and may be removed in the next major release (version 2.0.0). Please use 'copy' instead.", **kwargs)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4