colour.plotting.common Module¶
Common Plotting¶
Defines the common plotting objects:
colour_plotting_defaults()
colour_cycle()
canvas()
camera()
decorate()
boundaries()
display()
label_rectangles()
equal_axes3d()
colour_parameters_plot()
single_colour_plot()
multi_colour_plot()
image_plot()
-
colour.plotting.common.
PLOTTING_RESOURCES_DIRECTORY
= '/home/docs/checkouts/readthedocs.org/user_builds/colour/envs/v0.3.10/local/lib/python2.7/site-packages/colour_science-0.3.10-py2.7.egg/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
= 18¶ Default figure width.
DEFAULT_FIGURE_WIDTH : integer
-
colour.plotting.common.
DEFAULT_FIGURE_HEIGHT
= 11.124611797498108¶ Default figure height.
DEFAULT_FIGURE_HEIGHT : integer
-
colour.plotting.common.
DEFAULT_FIGURE_SIZE
= (18, 11.124611797498108)¶ Default figure size.
DEFAULT_FIGURE_SIZE : tuple
-
colour.plotting.common.
DEFAULT_FONT_SIZE
= 12¶ 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': 12, 'figure.figsize': (18, 11.124611797498108), 'ytick.labelsize': 12, 'xtick.labelsize': 12, 'axes.prop_cycle': <Mock name='mock.cycler()' id='139708318998096'>, 'axes.titlesize': 15.0, 'legend.fontsize': 10.8, 'axes.labelsize': 15.0}¶ Default plotting parameters.
DEFAULT_PARAMETERS : dict
-
colour.plotting.common.
DEFAULT_PLOTTING_ILLUMINANT
= array([ 0.3127, 0.329 ])¶ Default plotting illuminant – CIE Illuminant D Series D65.
DEFAULT_PLOTTING_ILLUMINANT : ndarray
-
colour.plotting.common.
DEFAULT_PLOTTING_ENCODING_CCTF
(L)¶ Default plotting encoding colour component transfer function / opto-electronic transfer function: sRGB.
DEFAULT_PLOTTING_ENCODING_CCTF : object
-
colour.plotting.common.
colour_plotting_defaults
(parameters=None)[source]¶ Enables Colour default plotting parameters.
Parameters: parameters (dict, optional) – Parameters to use for plotting. Returns: Definition success. Return type: bool
-
class
colour.plotting.common.
ColourParameter
[source]¶ Bases:
colour.plotting.common.ColourParameter
Defines a data structure for plotting a colour polygon in various spectral figures.
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 a new instance of the
ColourParameter
class.
-
colour.plotting.common.
colour_cycle
(**kwargs)[source]¶ Returns a colour cycle iterator using given colour map.
Other Parameters: - colour_cycle_map (unicode, optional) – Matplotlib colourmap name.
- colour_cycle_count (int, optional) – Colours count to pick in the colourmap.
Returns: Colour cycle iterator.
Return type: cycle
-
colour.plotting.common.
canvas
(**kwargs)[source]¶ Sets the figure size.
Other Parameters: figure_size (array_like, optional) – Array defining figure width and height such as figure_size = (width, height). Returns: Current figure. Return type: Figure
-
colour.plotting.common.
camera
(**kwargs)[source]¶ Sets the camera settings.
Other Parameters: - camera_aspect (unicode, optional) – Matplotlib axes aspect. Default is equal.
- elevation (numeric, optional) – Camera elevation.
- azimuth (numeric, optional) – Camera azimuth.
Returns: Current axes.
Return type: Axes
-
colour.plotting.common.
decorate
(**kwargs)[source]¶ Sets the figure decorations.
Other Parameters: - title (unicode, optional) – Figure title.
- x_label (unicode, optional) – X axis label.
- y_label (unicode, optional) – Y axis label.
- legend (bool, optional) – Whether to display the legend. Default is False.
- legend_columns (int, optional) – Number of columns in the legend. Default is 1.
- legend_location (unicode, optional) – Matplotlib legend location. Default is upper right.
- x_ticker (bool, optional) – Whether to display the X axis ticker. Default is True.
- y_ticker (bool, optional) – Whether to display the Y axis ticker. Default is True.
- x_ticker_locator (Locator, optional) – Locator type for the X axis ticker.
- y_ticker_locator (Locator, optional) – Locator type for the Y axis ticker.
- grid (bool, optional) – Whether to display the grid. Default is False.
- grid_which (unicode, optional) – Controls whether major tick grids, minor tick grids, or both are affected. Default is both.
- grid_axis (unicode, optional) – Controls which set of grid-lines are drawn. Default is both.
- x_axis_line (bool, optional) – Whether to draw the X axis line. Default is False.
- y_axis_line (bool, optional) – Whether to draw the Y axis line. Default is False.
- aspect (unicode, optional) – Matplotlib axes aspect.
- no_axes (bool, optional) – Whether to turn off the axes. Default is False.
Returns: Current axes.
Return type: Axes
-
colour.plotting.common.
boundaries
(**kwargs)[source]¶ Sets the plot boundaries.
Other Parameters: - bounding_box (array_like, optional) – Array defining current axes limits such bounding_box = (x min, x max, y min, y max).
- x_tighten (bool, optional) – Whether to tighten the X axis limit. Default is False.
- y_tighten (bool, optional) – Whether to tighten the Y axis limit. Default is False.
- limits (array_like, optional) – Array defining current axes limits such as limits = (x limit min, x limit max, y limit min, y limit max). limits argument values are added to the margins argument values to define the final bounding box for the current axes.
- margins (array_like, optional) – Array defining current axes margins such as margins = (x margin min, x margin max, y margin min, y margin max). margins argument values are added to the limits argument values to define the final bounding box for the current axes.
Returns: Current axes.
Return type: Axes
-
colour.plotting.common.
display
(**kwargs)[source]¶ Sets the figure display.
Other Parameters: - standalone (bool, optional) – Whether to show the figure.
- filename (unicode, optional) – Figure will be saved using given filename argument.
Returns: Current figure or None.
Return type: Figure
-
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:
-
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_parameters_plot
(colour_parameters, y0_plot=True, y1_plot=True, **kwargs)[source]¶ Plots given colour colour parameters.
Parameters: Other Parameters: **kwargs (dict, optional) – {
boundaries()
,canvas()
,decorate()
,display()
}, Please refer to the documentation of the previously listed definitions.Returns: Current figure or None.
Return type: Figure
Examples
>>> cp1 = ColourParameter( ... x=390, RGB=[0.03009021, 0, 0.12300545]) >>> cp2 = ColourParameter( ... x=391, RGB=[0.03434063, 0, 0.13328537], y0=0, y1=0.25) >>> cp3 = ColourParameter( ... x=392, RGB=[0.03826312, 0, 0.14276247], y0=0, y1=0.35) >>> cp4 = ColourParameter( ... x=393, RGB=[0.04191844, 0, 0.15158707], y0=0, y1=0.05) >>> cp5 = ColourParameter( ... x=394, RGB=[0.04535085, 0, 0.15986838], y0=0, y1=-.25) >>> colour_parameters_plot( ... [cp1, cp2, cp3, cp3, cp4, cp5])
-
colour.plotting.common.
single_colour_plot
(colour_parameter, **kwargs)[source]¶ Plots given colour.
Parameters: colour_parameter (ColourParameter) – ColourParameter.
Other Parameters: - **kwargs (dict, optional) – {
boundaries()
,canvas()
,decorate()
,display()
}, Please refer to the documentation of the previously listed definitions. - width (numeric, optional) – {
multi_colour_plot()
}, Colour polygon width. - height (numeric, optional) – {
multi_colour_plot()
}, Colour polygon height. - spacing (numeric, optional) – {
multi_colour_plot()
}, Colour polygons spacing. - across (int, optional) – {
multi_colour_plot()
}, Colour polygons count per row. - text_display (bool, optional) – {
multi_colour_plot()
}, Display colour text. - text_size (numeric, optional) – {
multi_colour_plot()
}, Colour text size. - text_offset (numeric, optional) – {
multi_colour_plot()
}, Colour text offset.
Returns: Current figure or None.
Return type: Figure
Examples
>>> RGB = (0.32315746, 0.32983556, 0.33640183) >>> single_colour_plot(ColourParameter(RGB))
- **kwargs (dict, optional) – {
-
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, background_colour=(1.0, 1.0, 1.0), **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.
- background_colour (array_like or unicode, optional) – Background colour.
Other Parameters: **kwargs (dict, optional) – {
boundaries()
,canvas()
,decorate()
,display()
}, Please refer to the documentation of the previously listed definitions.Returns: Current figure or None.
Return type: Figure
Examples
>>> cp1 = ColourParameter(RGB=(0.45293517, 0.31732158, 0.26414773)) >>> cp2 = ColourParameter(RGB=(0.77875824, 0.57726450, 0.50453169)) >>> multi_colour_plot([cp1, cp2])
-
colour.plotting.common.
image_plot
(image, label=None, label_size=15, label_colour=None, label_alpha=0.85, interpolation='nearest', colour_map=<Mock name='mock.cm.Greys_r' id='139708289753808'>, **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.
- interpolation (unicode, optional) – {‘nearest’, None, ‘none’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’, ‘mitchell’, ‘sinc’, ‘lanczos’} Image display interpolation.
- colour_map (unicode, optional) – Colour map used to display single channel images.
Other Parameters: **kwargs (dict, optional) – {
boundaries()
,canvas()
,decorate()
,display()
}, Please refer to the documentation of the previously listed definitions.Returns: Current figure or None.
Return type: Figure
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)