ColortableRegistry

class metpy.plots.ctables.ColortableRegistry[source]

Manages the collection of color tables.

Provides access to color tables, read collections of files, and generates matplotlib’s Normalize instances to go with the colortable.

Methods Summary

__init__(*args, **kwargs)

Initialize self.

add_colortable(fobj, name)

Add a color table from a file to the registry.

clear()

copy()

fromkeys([value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

get_colortable(name)

Get a color table from the registry.

get_with_boundaries(name, boundaries)

Get a color table from the registry with a corresponding norm.

get_with_range(name, start, end)

Get a color table from the registry with a corresponding norm.

get_with_steps(name, start, step)

Get a color table from the registry with a corresponding norm.

items()

keys()

pop(k[,d])

If key is not found, default is returned if given, otherwise KeyError is raised

popitem()

Remove and return a (key, value) pair as a 2-tuple.

scan_dir(path)

Scan a directory on disk for color table files and add them to the registry.

scan_resource(pkg, path)

Scan a resource directory for colortable files and add them to the registry.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

Methods Documentation

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

add_colortable(fobj, name)[source]

Add a color table from a file to the registry.

Parameters
  • fobj (file-like object) – The file to read the color table from

  • name (str) – The name under which the color table will be stored

clear()None.  Remove all items from D.
copy()a shallow copy of D
fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

get_colortable(name)[source]

Get a color table from the registry.

Parameters

name (str) – The name under which the color table will be stored

Returns

matplotlib.colors.ListedColormap – The color table corresponding to name

get_with_boundaries(name, boundaries)[source]

Get a color table from the registry with a corresponding norm.

Builds a matplotlib.colors.BoundaryNorm using boundaries.

Parameters
  • name (str) – The name under which the color table will be stored

  • boundaries (array_like) – The list of boundaries for the norm

Returns

matplotlib.colors.BoundaryNorm, matplotlib.colors.ListedColormap – The boundary norm based on boundaries, and the color table itself.

get_with_range(name, start, end)[source]

Get a color table from the registry with a corresponding norm.

Builds a matplotlib.colors.BoundaryNorm using start, end, and the number of colors, based on the color table obtained from name.

Parameters
  • name (str) – The name under which the color table will be stored

  • start (float) – The starting boundary

  • end (float) – The ending boundary

Returns

matplotlib.colors.BoundaryNorm, matplotlib.colors.ListedColormap – The boundary norm based on start and end with the number of colors from the number of entries matching the color table, and the color table itself.

get_with_steps(name, start, step)[source]

Get a color table from the registry with a corresponding norm.

Builds a matplotlib.colors.BoundaryNorm using start, step, and the number of colors, based on the color table obtained from name.

Parameters
  • name (str) – The name under which the color table will be stored

  • start (float) – The starting boundary

  • step (float) – The step between boundaries

Returns

matplotlib.colors.BoundaryNorm, matplotlib.colors.ListedColormap – The boundary norm based on start and step with the number of colors from the number of entries matching the color table, and the color table itself.

items()a set-like object providing a view on D’s items
keys()a set-like object providing a view on D’s keys
pop(k[, d])v, remove specified key and return the corresponding value.

If key is not found, default is returned if given, otherwise KeyError is raised

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

scan_dir(path)[source]

Scan a directory on disk for color table files and add them to the registry.

Parameters

path (str) – The path to the directory with the color tables

scan_resource(pkg, path)[source]

Scan a resource directory for colortable files and add them to the registry.

Parameters
  • pkg (str) – The package containing the resource directory

  • path (str) – The path to the directory with the color tables

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F)None.  Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()an object providing a view on D’s values