colour.plotting.common Module

Common Plotting

Defines the common plotting objects:

colour.plotting.common.PLOTTING_RESOURCES_DIRECTORY = '/colour-science/colour/colour/plotting/resources'

Resources directory.

RESOURCES_DIRECTORY : unicode

colour.plotting.common.DEFAULT_FIGURE_ASPECT_RATIO = 0.6180339887498949

Default figure aspect ratio (Golden Number).

DEFAULT_FIGURE_ASPECT_RATIO : float

colour.plotting.common.DEFAULT_FIGURE_WIDTH = 12

Default figure width.

DEFAULT_FIGURE_WIDTH : integer

colour.plotting.common.DEFAULT_FIGURE_HEIGHT = 7.4164078649987388

Default figure height.

DEFAULT_FIGURE_HEIGHT : integer

colour.plotting.common.DEFAULT_FIGURE_SIZE = (12, 7.4164078649987388)

Default figure size.

DEFAULT_FIGURE_SIZE : tuple

colour.plotting.common.DEFAULT_FONT_SIZE = 10

Default figure font size.

DEFAULT_FONT_SIZE : numeric

colour.plotting.common.DEFAULT_COLOUR_CYCLE = ('r', 'g', 'b', 'c', 'm', 'y', 'k')

Default colour cycle for plots.

DEFAULT_COLOUR_CYCLE : tuple {‘r’, ‘g’, ‘b’, ‘c’, ‘m’, ‘y’, ‘k’}

colour.plotting.common.DEFAULT_HATCH_PATTERNS = ('\\\\', 'o', 'x', '.', '*', '//')

Default hatch patterns for bar plots.

DEFAULT_HATCH_PATTERNS : tuple {‘\’, ‘o’, ‘x’, ‘.’, ‘*’, ‘//’}

colour.plotting.common.DEFAULT_PARAMETERS = {'font.size': 10, 'figure.figsize': (12, 7.4164078649987388), 'ytick.labelsize': 10, 'xtick.labelsize': 10, 'axes.titlesize': 12.5, 'legend.fontsize': 9.0, 'axes.labelsize': 12.5, 'axes.color_cycle': ('r', 'g', 'b', 'c', 'm', 'y', 'k')}

Default plotting parameters.

DEFAULT_PARAMETERS : dict

colour.plotting.common.DEFAULT_PLOTTING_ILLUMINANT = (0.31271, 0.32902)

Default plotting illuminant: CIE Illuminant D Series D65.

DEFAULT_PLOTTING_ILLUMINANT : tuple

colour.plotting.common.DEFAULT_PLOTTING_OECF(value)

Default plotting OECF / transfer function: sRGB.

DEFAULT_PLOTTING_OECF : object

class colour.plotting.common.ColourParameter

Bases: tuple

ColourParameter(name, RGB, x, y0, y1)

RGB

Alias for field number 1

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

name

Alias for field number 0

x

Alias for field number 2

y0

Alias for field number 3

y1

Alias for field number 4

colour.plotting.common.colour_cycle(**kwargs)[source]

Returns a colour cycle iterator using given colour map.

Parameters:**kwargs (**) – {‘colour_cycle_map’, ‘colour_cycle_count’} Keywords arguments such as {'colour_cycle_map': unicode (Matplotlib colormap name), 'colour_cycle_count': int}
Returns:Colour cycle iterator.
Return type:cycle
colour.plotting.common.canvas(**kwargs)[source]

Sets the figure size.

Parameters:**kwargs (**) – {‘figure_size’, } Keywords arguments such as {'figure_size': array_like (width, height), }
Returns:Current figure.
Return type:Figure
colour.plotting.common.camera(**kwargs)[source]

Sets the camera settings.

Parameters:**kwargs (**) – {‘camera_aspect’, ‘elevation’, ‘azimuth’} Keywords arguments such as {'camera_aspect': unicode (Matplotlib axes aspect), 'elevation' : numeric, 'azimuth' : numeric}
Returns:Definition success.
Return type:bool
colour.plotting.common.decorate(**kwargs)[source]

Sets the figure decorations.

Parameters:**kwargs (**) – {‘title’, ‘x_label’, ‘y_label’, ‘legend’, ‘legend_columns’, ‘legend_location’, ‘x_ticker’, ‘y_ticker’, ‘x_ticker_locator’, ‘y_ticker_locator’, ‘grid’, ‘grid_which’, ‘grid_axis’, ‘x_axis_line’, ‘y_axis_line’, ‘aspect’, ‘no_axes3d’} Keywords arguments such as {'title': unicode (figure title), 'x_label': unicode (X axis label), 'y_label': unicode (Y axis label), 'legend': bool, 'legend_columns': int, 'legend_location': unicode (Matplotlib legend location), 'x_ticker': bool, 'y_ticker': bool, 'x_ticker_locator': Locator, 'y_ticker_locator': Locator, 'grid': bool, 'grid_which': unicode, 'grid_axis': unicode, 'x_axis_line': bool, 'y_axis_line': bool, 'aspect': unicode (Matplotlib axes aspect), 'no_axes3d': bool}
Returns:Definition success.
Return type:bool
colour.plotting.common.boundaries(**kwargs)[source]

Sets the plot boundaries.

Parameters:**kwargs (**) – {‘bounding_box’, ‘x_tighten’, ‘y_tighten’, ‘limits’, ‘margins’} Keywords arguments such as {'bounding_box': array_like (x min, x max, y min, y max), 'x_tighten': bool, 'y_tighten': bool, 'limits': array_like (x min, x max, y min, y max), 'limits': array_like (x min, x max, y min, y max)}
Returns:Definition success.
Return type:bool
colour.plotting.common.display(**kwargs)[source]

Sets the figure display.

Parameters:**kwargs (**) – {‘standalone’, ‘filename’} Keywords arguments such as {'standalone': bool (figure is shown), 'filename': unicode (figure is saved as `filename`)}
Returns:Definition success.
Return type:bool
colour.plotting.common.label_rectangles(rectangles, rotation='vertical', text_size=10, offset=None)[source]

Add labels above given rectangles.

Parameters:
  • rectangles (object) – Rectangles to used to set the labels value and position.
  • rotation (unicode, optional) – {‘horizontal’, ‘vertical’}, Labels orientation.
  • text_size (numeric, optional) – Labels text size.
  • offset (array_like, optional) – Labels offset as percentages of the largest rectangle dimensions.
Returns:

Definition success.

Return type:

bool

colour.plotting.common.equal_axes3d(axes)[source]

Sets equal aspect ratio to given 3d axes.

Parameters:axes (object) – Axis to set the equal aspect ratio.
Returns:Definition success.
Return type:bool
colour.plotting.common.get_RGB_colourspace(colourspace)[source]

Returns the RGB colourspace with given name.

Parameters:colourspace (unicode) – RGB colourspace name.
Returns:RGB colourspace.
Return type:RGB_Colourspace
Raises:KeyError – If the given RGB colourspace is not found in the factory RGB colourspaces.
colour.plotting.common.get_cmfs(cmfs)[source]

Returns the colour matching functions with given name.

Parameters:cmfs (unicode) – Colour matching functions name.
Returns:Colour matching functions.
Return type:RGB_ColourMatchingFunctions or XYZ_ColourMatchingFunctions
Raises:KeyError – If the given colour matching functions is not found in the factory colour matching functions.
colour.plotting.common.get_illuminant(illuminant)[source]

Returns the illuminant with given name.

Parameters:illuminant (unicode) – Illuminant name.
Returns:Illuminant.
Return type:SpectralPowerDistribution
Raises:KeyError – If the given illuminant is not found in the factory illuminants.
colour.plotting.common.colour_parameter(name=None, RGB=None, x=None, y0=None, y1=None)[source]

Defines a factory for colour.plotting.plots.COLOUR_PARAMETER attribute.

Parameters:
  • name (unicode, optional) – Colour name.
  • RGB (array_like, optional) – RGB Colour.
  • x (numeric, optional) – X data.
  • y0 (numeric, optional) – Y0 data.
  • y1 (numeric, optional) – Y1 data.
Returns:

ColourParameter.

Return type:

ColourParameter

colour.plotting.common.colour_parameters_plot(colour_parameters, y0_plot=True, y1_plot=True, **kwargs)[source]

Plots given colour colour_parameters.

Parameters:
  • colour_parameters (list) – ColourParameter sequence.
  • y0_plot (bool, optional) – Plot y0 line.
  • y1_plot (bool, optional) – Plot y1 line.
  • **kwargs (**) – Keywords arguments.
Returns:

Definition success.

Return type:

bool

Examples

>>> cp1 = colour_parameter(
...     x=390, RGB=[0.03009021, 0, 0.12300545])
>>> cp2 = colour_parameter(
...     x=391, RGB=[0.03434063, 0, 0.13328537], y0=0, y1=0.25)
>>> cp3 = colour_parameter(
...     x=392, RGB=[0.03826312, 0, 0.14276247], y0=0, y1=0.35)
>>> cp4 = colour_parameter(
...     x=393, RGB=[0.04191844, 0, 0.15158707], y0=0, y1=0.05)
>>> cp5 = colour_parameter(
...     x=394, RGB=[0.04535085, 0, 0.15986838], y0=0, y1=-.25)
>>> colour_parameters_plot(
...     [cp1, cp2, cp3, cp3, cp4, cp5])  
True
colour.plotting.common.single_colour_plot(colour_parameter, **kwargs)[source]

Plots given colour.

Parameters:
  • colour_parameter (ColourParameter) – ColourParameter.
  • **kwargs (**) – Keywords arguments.
Returns:

Definition success.

Return type:

bool

Examples

>>> RGB = (0.32315746, 0.32983556, 0.33640183)
>>> single_colour_plot(colour_parameter(RGB))  
True
colour.plotting.common.multi_colour_plot(colour_parameters, width=1, height=1, spacing=0, across=3, text_display=True, text_size='large', text_offset=0.075, **kwargs)[source]

Plots given colours.

Parameters:
  • colour_parameters (list) – ColourParameter sequence.
  • width (numeric, optional) – Colour polygon width.
  • height (numeric, optional) – Colour polygon height.
  • spacing (numeric, optional) – Colour polygons spacing.
  • across (int, optional) – Colour polygons count per row.
  • text_display (bool, optional) – Display colour text.
  • text_size (numeric, optional) – Colour text size.
  • text_offset (numeric, optional) – Colour text offset.
  • **kwargs (**) – Keywords arguments.
Returns:

Definition success.

Return type:

bool

Examples

>>> cp1 = colour_parameter(RGB=(0.45293517, 0.31732158, 0.26414773))
>>> cp2 = colour_parameter(RGB=(0.77875824, 0.57726450, 0.50453169))
>>> multi_colour_plot([cp1, cp2])  
True
colour.plotting.common.image_plot(image, label=None, label_size=15, label_colour=None, label_alpha=0.85, **kwargs)[source]

Plots given image.

Parameters:
  • image (array_like) – Image to plot.
  • label (unicode, optional) – Image label.
  • label_size (int, optional) – Image label font size.
  • label_colour (array_like or unicode, optional) – Image label colour.
  • label_alpha (numeric, optional) – Image label alpha.
  • **kwargs (**) – Keywords arguments.
Returns:

Definition success.

Return type:

bool

Examples

>>> import os
>>> from colour import read_image
>>> path = os.path.join(
...     'resources',
...     ('CIE_1931_Chromaticity_Diagram'
...     '_CIE_1931_2_Degree_Standard_Observer.png'))
>>> image = read_image(path)  
>>> image_plot(image)  
True