Main Content


Plot color reproduction on chromaticity diagram



plotChromaticity(colorValues) plots on a chromaticity diagram the measured and reference colors, colorValues, for color patch regions of interest (ROIs) in a test chart.

plotChromaticity plots an empty chromaticity diagram.

plotChromaticity(___,Name=Value) adjusts aspects of the display using name-value arguments.


collapse all

This example shows how to display the chromaticity diagram from measurements of color accuracy on an Imatest® eSFR chart.

Read an image of an eSFR chart into the workspace.

I = imread("eSFRTestImage.jpg");

Create an esfrChart object. Display the chart, highlighting the 16 color patches.

chart = esfrChart(I);
displayChart(chart,displayEdgeROIs=false, ...

Measure the color in all color patch ROIs.

colorTable = measureColor(chart);

Plot the measured and reference colors in the CIE 1976 L*a*b* color space on a chromaticity diagram. Red circles indicate the reference color and green circles indicate the measured color of each color patch. The chromaticity diagram does not portray the brightness of color.


Read an image of a ColorChecker® chart into the workspace.

I = imread("colorCheckerTestImage.jpg");

Create a colorChecker object, then display the chart with ROI annotations.

chart = colorChecker(I);

Measure the color in each color patch ROI.

colorTable = measureColor(chart);

Plot the measured and reference colors on a chromaticity diagram.


Convert sRGB primary colors to the XYZ color space.

xyz_primaries = rgb2xyz([1 0 0; 0 1 0; 0 0 1]);

Normalize the x and y values of the primary colors.

xyzMag = sum(xyz_primaries,2);
x_primary = xyz_primaries(:,1)./xyzMag;
y_primary = xyz_primaries(:,2)./xyzMag;

Calculate and normalize the D65 white point.

wp = whitepoint('D65');

Normalize the x and y values of the white point.

wpMag = sum(wp,2);
x_whitepoint = wp(:,1)./wpMag;
y_whitepoint = wp(:,2)./wpMag;

Create an empty 2-D chromaticity diagram.


Add the (x,y) coordinates of the primaries and white point to the chromaticity diagram.

hold on
plot([x_primary; x_primary],[y_primary; y_primary],'k')
hold off

Display a 3-D color solid of the u'v'L color space on an empty chromaticity diagram. Include all u'v'L colors by specifying the brightness threshold as 0.


Input Arguments

collapse all

Color values in each color patch, specified as a table with n rows, where n is the number of color ROIs. To obtain a table of color values, use the measureColor function.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: plotChromaticity(colorValues,displayROIIndex=false) turns off the display of the ROI indices on the chromaticity diagram.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: plotChromaticity(colorValues,"displayROIIndex",false) turns off the display of the ROI indices on the chromaticity diagram.

Brightness threshold, specified as a number in the range [0, 1]. The plotChromaticity function does not display color values with a Y or L value (depending on the color space) less than the brightness threshold.

Color space, specified as "xy" to plot in the xyY color space or "uv" to plot in the u'v'L color space.

Data Types: char | string

Display ROI index labels, specified as a numeric or logical 1 (true) or 0 (false). When displayROIIndex is true, then the plotChromaticity function overlays color patch ROI index labels on the chromaticity diagram.

Parent axes of the chromaticity diagram, specified as an Axes object.

Dimensionality of chromaticity diagram, specified as 2 for a 2-D projection or 3 for a 3-D color solid.


  • The reference L*a*b* values of the colorValues measured from a colorChecker object are for the "After November 2014" version of the ColorChecker® chart. The white point of the reference values is the CIE standard illuminant D50.

Version History

Introduced in R2017b