I'm trying to make a chromaticity diagram in tikZ, does anyone know how to make one?
I want this
My issue is not in forming the spectral locus that I can do, right now I'm only using three points but I'm trying to color the diagram in. Does any one have any pointers or have they done this before?
Also, yes I know chromaticity diagrams should never be colored in beacsue our displays can't produce the full diagram, and etc. So color science 101 aside.
Matlab code to make the shape of the locus
cie.lambda = [380:5:780];
%load CIE color matching data
cie.cmf2deg = 1.0e+02 * [3.800000000000000 0.000013680000000 0.000000390000000 0.000064500000000;
3.850000000000000 0.000022360000000 0.000000640000000 0.000105500000000;
3.900000000000000 0.000042430000000 0.000001200000000 0.000200500000000;
3.950000000000000 0.000076500000000 0.000002170000000 0.000362100000000;
4.000000000000000 0.000143100000000 0.000003960000000 0.000678500000000;
4.050000000000000 0.000231900000000 0.000006400000000 0.001102000000000;
4.100000000000000 0.000435100000000 0.000012100000000 0.002074000000000;
4.150000000000000 0.000776300000000 0.000021800000000 0.003713000000000;
4.200000000000000 0.001343800000000 0.000040000000000 0.006456000000000;
4.250000000000000 0.002147700000000 0.000073000000000 0.010390500000000;
4.300000000000000 0.002839000000000 0.000116000000000 0.013856000000000;
4.350000000000000 0.003285000000000 0.000168400000000 0.016229600000000;
4.400000000000000 0.003482800000000 0.000230000000000 0.017470600000000;
4.450000000000000 0.003480600000000 0.000298000000000 0.017826000000000;
4.500000000000000 0.003362000000000 0.000380000000000 0.017721100000000;
4.550000000000000 0.003187000000000 0.000480000000000 0.017441000000000;
4.600000000000000 0.002908000000000 0.000600000000000 0.016692000000000;
4.650000000000000 0.002511000000000 0.000739000000000 0.015281000000000;
4.700000000000000 0.001953600000000 0.000909800000000 0.012876400000000;
4.750000000000000 0.001421000000000 0.001126000000000 0.010419000000000;
4.800000000000000 0.000956400000000 0.001390200000000 0.008129500000000;
4.850000000000000 0.000579500000000 0.001693000000000 0.006162000000000;
4.900000000000000 0.000320100000000 0.002080200000000 0.004651800000000;
4.950000000000000 0.000147000000000 0.002586000000000 0.003533000000000;
5.000000000000000 0.000049000000000 0.003230000000000 0.002720000000000;
5.050000000000000 0.000024000000000 0.004073000000000 0.002123000000000;
5.100000000000000 0.000093000000000 0.005030000000000 0.001582000000000;
5.150000000000000 0.000291000000000 0.006082000000000 0.001117000000000;
5.200000000000000 0.000632700000000 0.007100000000000 0.000782500000000;
5.250000000000000 0.001096000000000 0.007932000000000 0.000572500000000;
5.300000000000000 0.001655000000000 0.008620000000000 0.000421600000000;
5.350000000000000 0.002257500000000 0.009148500000000 0.000298400000000;
5.400000000000000 0.002904000000000 0.009540000000000 0.000203000000000;
5.450000000000000 0.003597000000000 0.009803000000000 0.000134000000000;
5.500000000000000 0.004334500000000 0.009949500000000 0.000087500000000;
5.550000000000000 0.005120500000000 0.010000000000000 0.000057500000000;
5.600000000000000 0.005945000000000 0.009950000000000 0.000039000000000;
5.650000000000000 0.006784000000000 0.009786000000000 0.000027500000000;
5.700000000000000 0.007621000000000 0.009520000000000 0.000021000000000;
5.750000000000000 0.008425000000000 0.009154000000000 0.000018000000000;
5.800000000000000 0.009163000000000 0.008700000000000 0.000016500000000;
5.850000000000000 0.009786000000000 0.008163000000000 0.000014000000000;
5.900000000000000 0.010263000000000 0.007570000000000 0.000011000000000;
5.950000000000000 0.010567000000000 0.006949000000000 0.000010000000000;
6.000000000000000 0.010622000000000 0.006310000000000 0.000008000000000;
6.050000000000000 0.010456000000000 0.005668000000000 0.000006000000000;
6.100000000000000 0.010026000000000 0.005030000000000 0.000003400000000;
6.150000000000000 0.009384000000000 0.004412000000000 0.000002400000000;
6.200000000000000 0.008544500000000 0.003810000000000 0.000001900000000;
6.250000000000000 0.007514000000000 0.003210000000000 0.000001000000000;
6.300000000000000 0.006424000000000 0.002650000000000 0.000000500000000;
6.350000000000000 0.005419000000000 0.002170000000000 0.000000300000000;
6.400000000000000 0.004479000000000 0.001750000000000 0.000000200000000;
6.450000000000000 0.003608000000000 0.001382000000000 0.000000100000000;
6.500000000000000 0.002835000000000 0.001070000000000 0;
6.550000000000000 0.002187000000000 0.000816000000000 0;
6.600000000000000 0.001649000000000 0.000610000000000 0;
6.650000000000000 0.001212000000000 0.000445800000000 0;
6.700000000000000 0.000874000000000 0.000320000000000 0;
6.750000000000000 0.000636000000000 0.000232000000000 0;
6.800000000000000 0.000467700000000 0.000170000000000 0;
6.850000000000000 0.000329000000000 0.000119200000000 0;
6.900000000000000 0.000227000000000 0.000082100000000 0;
6.950000000000000 0.000158400000000 0.000057230000000 0;
7.000000000000000 0.000113590000000 0.000041020000000 0;
7.050000000000000 0.000081110000000 0.000029290000000 0;
7.100000000000000 0.000057900000000 0.000020910000000 0;
7.150000000000000 0.000041090000000 0.000014840000000 0;
7.200000000000000 0.000028990000000 0.000010470000000 0;
7.250000000000000 0.000020490000000 0.000007400000000 0;
7.300000000000000 0.000014400000000 0.000005200000000 0;
7.350000000000000 0.000010000000000 0.000003610000000 0;
7.400000000000000 0.000006900000000 0.000002490000000 0;
7.450000000000000 0.000004760000000 0.000001720000000 0;
7.500000000000000 0.000003320000000 0.000001200000000 0;
7.550000000000000 0.000002350000000 0.000000850000000 0;
7.600000000000000 0.000001660000000 0.000000600000000 0;
7.650000000000000 0.000001170000000 0.000000420000000 0;
7.700000000000000 0.000000830000000 0.000000300000000 0;
7.750000000000000 0.000000590000000 0.000000210000000 0;
7.800000000000000 0.000000420000000 0.000000150000000 0;];
cie.illE = ones(length(cie.lambda),1); %equal energy illuminant
%Interpolate data to specifed range
interpMethod = 'linear';
cie.cmf2deg = interp1(cie.cmf2deg(:,1),cie.cmf2deg(:,2:end),cie.lambda(:),interpMethod);
cie.cmf2deg=cie.cmf2deg';
locus = [cie.cmf2deg(1,:)./sum(cie.cmf2deg);cie.cmf2deg(2,:)./sum(cie.cmf2deg)];
plot(locus(1,[1:81,1]),locus(2,[1:81,1]), 'b-');
v = locus(1,[1:81,1]);
g = locus(2,[1:81,1]);
for ii = 1:81
fprintf('(%f,%f)',v(ii)*10,g(ii)*10)
fprintf('--')
if mod(ii,10) == 0
fprintf('\n')
end
end
If you copy and paste from Matlab you get this
\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{fadings}
\usepackage[latin1]{inputenc}
\author{}
\date{}
\title{}
\begin{document}
\begin{tikzpicture}
\draw [<->,ultra thick] (0,10) -- (0,0) -- (10,0);
\draw [help lines] (0,0) grid (10,10);
\draw [thick] (1.741123,0.049637)--(1.740078,0.049805)--(1.738008,0.049154)--(1.735599,0.049232)--(1.733369,0.047967)--(1.730210,0.047751)--(1.725766,0.047993)--(1.720866,0.048325)--(1.714074,0.051022)--(1.703010,0.057885)--
(1.688775,0.069002)--(1.668953,0.085556)--(1.644118,0.108576)--(1.611046,0.137934)--(1.566409,0.177048)--(1.509854,0.227402)--(1.439604,0.297030)--(1.355027,0.398791)--(1.241185,0.578025)--(1.095943,0.868425)--
(0.912935,1.327021)--(0.687059,2.007232)--(0.453907,2.949760)--(0.234599,4.127035)--(0.081680,5.384231)--(0.038585,6.548232)--(0.138702,7.501864)--(0.388518,8.120160)--(0.743024,8.338031)--(1.141607,8.262070)--
(1.547221,8.058635)--(1.928762,7.816291)--(2.296197,7.543291)--(2.657751,7.243239)--(3.016039,6.923077)--(3.373633,6.588483)--(3.731015,6.244509)--(4.087363,5.896069)--(4.440625,5.547139)--(4.787748,5.202023)--
(5.124864,4.865908)--(5.447865,4.544341)--(5.751513,4.242322)--(6.029328,3.964966)--(6.270366,3.724911)--(6.482331,3.513949)--(6.657636,3.340107)--(6.800788,3.197472)--(6.915040,3.083422)--(7.006061,2.993007)--
(7.079178,2.920271)--(7.140316,2.859289)--(7.190329,2.809350)--(7.230316,2.769484)--(7.259923,2.740077)--(7.282717,2.717283)--(7.299690,2.700310)--(7.310894,2.689106)--(7.319933,2.680067)--(7.327189,2.672811)--
(7.334170,2.665830)--(7.340473,2.659527)--(7.343902,2.656098)--(7.345917,2.654083)--(7.346873,2.653127)--(7.346920,2.653080)--(7.346783,2.653217)--(7.346683,2.653317)--(7.346680,2.653320)--(7.346719,2.653281)--
(7.346939,2.653061)--(7.347539,2.652461)--(7.348243,2.651757)--(7.345679,2.654321)--(7.345133,2.654867)--(7.343750,2.656250)--(7.345133,2.654867)--(7.358491,2.641509)--(7.345133,2.654867)--(7.375000,2.625000)--
(7.368421,2.631579)--cycle;
\end{tikzpicture}
\end{document}
Here is what I get when it try to use code to color it
\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{fadings}
\usepackage[latin1]{inputenc}
\author{}
\date{}
\title{}
\begin{document}
\begin{tikzpicture}
\draw [<->,ultra thick] (0,10) -- (0,0) -- (10,0);
\draw [help lines] (0,0) grid (10,10);
\fill [blue] (1.741123,0.049637)--(1.740078,0.049805)--(1.738008,0.049154)--
(1.735599,0.049232)--(1.733369,0.047967)--(1.730210,0.047751)--(1.725766,0.047993)--(1.720866,0.048325)--(1.714074,0.051022)--(1.703010,0.057885)--
(1.688775,0.069002)--(1.668953,0.085556)--(1.644118,0.108576)--(1.611046,0.137934)--(1.566409,0.177048)--(1.509854,0.227402)--(1.439604,0.297030)--(1.355027,0.398791)--(1.241185,0.578025)--(1.095943,0.868425)--
(0.912935,1.327021)--(0.687059,2.007232)--(0.453907,2.949760)--(0.234599,4.127035)--(0.081680,5.384231)--(0.038585,6.548232)--(0.138702,7.501864)--(0.388518,8.120160)--(0.743024,8.338031)--(1.141607,8.262070)--
(1.547221,8.058635)--(1.928762,7.816291)--(2.296197,7.543291)--(2.657751,7.243239)--(3.016039,6.923077)--(3.373633,6.588483)--(3.731015,6.244509)--(4.087363,5.896069)--(4.440625,5.547139)--(4.787748,5.202023)--
(5.124864,4.865908)--(5.447865,4.544341)--(5.751513,4.242322)--(6.029328,3.964966)--(6.270366,3.724911)--(6.482331,3.513949)--(6.657636,3.340107)--(6.800788,3.197472)--(6.915040,3.083422)--(7.006061,2.993007)--
(7.079178,2.920271)--(7.140316,2.859289)--(7.190329,2.809350)--(7.230316,2.769484)--(7.259923,2.740077)--(7.282717,2.717283)--(7.299690,2.700310)--(7.310894,2.689106)--(7.319933,2.680067)--(7.327189,2.672811)--
(7.334170,2.665830)--(7.340473,2.659527)--(7.343902,2.656098)--(7.345917,2.654083)--(7.346873,2.653127)--(7.346920,2.653080)--(7.346783,2.653217)--(7.346683,2.653317)--(7.346680,2.653320)--(7.346719,2.653281)--
(7.346939,2.653061)--(7.347539,2.652461)--(7.348243,2.651757)--(7.345679,2.654321)--(7.345133,2.654867)--(7.343750,2.656250)--(7.345133,2.654867)--(7.358491,2.641509)--(7.345133,2.654867)--(7.375000,2.625000)--
(7.368421,2.631579)--cycle;
\fill [red, path fading =west] (1.741123,0.049637)--(1.740078,0.049805)--(1.738008,0.049154)--(1.735599,0.049232)--(1.733369,0.047967)--(1.730210,0.047751)--(1.725766,0.047993)--(1.720866,0.048325)--(1.714074,0.051022)--(1.703010,0.057885)--
(1.688775,0.069002)--(1.668953,0.085556)--(1.644118,0.108576)--(1.611046,0.137934)--(1.566409,0.177048)--(1.509854,0.227402)--(1.439604,0.297030)--(1.355027,0.398791)--(1.241185,0.578025)--(1.095943,0.868425)--
(0.912935,1.327021)--(0.687059,2.007232)--(0.453907,2.949760)--(0.234599,4.127035)--(0.081680,5.384231)--(0.038585,6.548232)--(0.138702,7.501864)--(0.388518,8.120160)--(0.743024,8.338031)--(1.141607,8.262070)--
(1.547221,8.058635)--(1.928762,7.816291)--(2.296197,7.543291)--(2.657751,7.243239)--(3.016039,6.923077)--(3.373633,6.588483)--(3.731015,6.244509)--(4.087363,5.896069)--(4.440625,5.547139)--(4.787748,5.202023)--
(5.124864,4.865908)--(5.447865,4.544341)--(5.751513,4.242322)--(6.029328,3.964966)--(6.270366,3.724911)--(6.482331,3.513949)--(6.657636,3.340107)--(6.800788,3.197472)--(6.915040,3.083422)--(7.006061,2.993007)--
(7.079178,2.920271)--(7.140316,2.859289)--(7.190329,2.809350)--(7.230316,2.769484)--(7.259923,2.740077)--(7.282717,2.717283)--(7.299690,2.700310)--(7.310894,2.689106)--(7.319933,2.680067)--(7.327189,2.672811)--
(7.334170,2.665830)--(7.340473,2.659527)--(7.343902,2.656098)--(7.345917,2.654083)--(7.346873,2.653127)--(7.346920,2.653080)--(7.346783,2.653217)--(7.346683,2.653317)--(7.346680,2.653320)--(7.346719,2.653281)--
(7.346939,2.653061)--(7.347539,2.652461)--(7.348243,2.651757)--(7.345679,2.654321)--(7.345133,2.654867)--(7.343750,2.656250)--(7.345133,2.654867)--(7.358491,2.641509)--(7.345133,2.654867)--(7.375000,2.625000)--
(7.368421,2.631579)--cycle;
\fill [green,path fading =south] (1.741123,0.049637)--(1.740078,0.049805)--(1.738008,0.049154)--(1.735599,0.049232)--(1.733369,0.047967)--(1.730210,0.047751)--(1.725766,0.047993)--(1.720866,0.048325)--(1.714074,0.051022)--(1.703010,0.057885)--
(1.688775,0.069002)--(1.668953,0.085556)--(1.644118,0.108576)--(1.611046,0.137934)--(1.566409,0.177048)--(1.509854,0.227402)--(1.439604,0.297030)--(1.355027,0.398791)--(1.241185,0.578025)--(1.095943,0.868425)--
(0.912935,1.327021)--(0.687059,2.007232)--(0.453907,2.949760)--(0.234599,4.127035)--(0.081680,5.384231)--(0.038585,6.548232)--(0.138702,7.501864)--(0.388518,8.120160)--(0.743024,8.338031)--(1.141607,8.262070)--
(1.547221,8.058635)--(1.928762,7.816291)--(2.296197,7.543291)--(2.657751,7.243239)--(3.016039,6.923077)--(3.373633,6.588483)--(3.731015,6.244509)--(4.087363,5.896069)--(4.440625,5.547139)--(4.787748,5.202023)--
(5.124864,4.865908)--(5.447865,4.544341)--(5.751513,4.242322)--(6.029328,3.964966)--(6.270366,3.724911)--(6.482331,3.513949)--(6.657636,3.340107)--(6.800788,3.197472)--(6.915040,3.083422)--(7.006061,2.993007)--
(7.079178,2.920271)--(7.140316,2.859289)--(7.190329,2.809350)--(7.230316,2.769484)--(7.259923,2.740077)--(7.282717,2.717283)--(7.299690,2.700310)--(7.310894,2.689106)--(7.319933,2.680067)--(7.327189,2.672811)--
(7.334170,2.665830)--(7.340473,2.659527)--(7.343902,2.656098)--(7.345917,2.654083)--(7.346873,2.653127)--(7.346920,2.653080)--(7.346783,2.653217)--(7.346683,2.653317)--(7.346680,2.653320)--(7.346719,2.653281)--
(7.346939,2.653061)--(7.347539,2.652461)--(7.348243,2.651757)--(7.345679,2.654321)--(7.345133,2.654867)--(7.343750,2.656250)--(7.345133,2.654867)--(7.358491,2.641509)--(7.345133,2.654867)--(7.375000,2.625000)--
(7.368421,2.631579)--cycle;
\end{tikzpicture}
\end{document}