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)

add_colortable(fobj, name)

Add a color table from a file to the registry.

clear()

Remove all items from the dict.

copy()

Return a shallow copy of the dict.

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

Return a set-like object providing a view on the dict's items.

keys()

Return a set-like object providing a view on the dict's keys.

pop(k[,d])

If the key is not found, return the default if given; otherwise, raise a KeyError.

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.keys(): 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()

Return an object providing a view on the dict's values.

Methods Documentation

__init__(*args, **kwargs)#
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()#

Remove all items from the dict.

copy()#

Return a shallow copy of the dict.

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()#

Return a set-like object providing a view on the dict’s items.

keys()#

Return a set-like object providing a view on the dict’s keys.

pop(k[, d]) v, remove specified key and return the corresponding value.#

If the key is not found, return the default if given; otherwise, raise a KeyError.

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 mapping/iterable E and F.#

If E is present and has a .keys() method, then does: for k in E.keys(): 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()#

Return an object providing a view on the dict’s values.