4

I'm trying to make a good-looking photopic luminosity function plot. So I want to make colored plot, but its colormap should depend on X values. Is it possible with pgfplots?

I'll also appreciate any ideas on such colored plot.

Here's MWE, sorry for so many coordinates. I haven't changed colors to [violet ... red] yet.

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
    \begin{axis}[
        axis x line=bottom,
        axis y line=left,
        ymax=1.1,xmin=390,xmax=710,
        xlabel=$\lambda$,
        ylabel=$Relative~Sensivity$]
    \addplot[smooth,mesh,line width=1.5pt]
        plot coordinates {
            (401,2.85222E-03)
            (402,3.29912E-03)
            (403,3.79747E-03)
            (404,4.35277E-03)
            (405,4.97172E-03)
            (406,5.66101E-03)
            (407,6.42161E-03)
            (408,7.25031E-03)
            (409,8.14017E-03)
            (410,9.07986E-03)
            (411,1.00561E-02)
            (412,1.10646E-02)
            (413,1.21052E-02)
            (414,1.31801E-02)
            (415,1.42938E-02)
            (416,1.54500E-02)
            (417,1.66409E-02)
            (418,1.78530E-02)
            (419,1.90702E-02)
            (420,2.02737E-02)
            (421,2.14481E-02)
            (422,2.26004E-02)
            (423,2.37479E-02)
            (424,2.49125E-02)
            (425,2.61211E-02)
            (426,2.73992E-02)
            (427,2.87499E-02)
            (428,3.01691E-02)
            (429,3.16514E-02)
            (430,3.31904E-02)
            (431,3.47791E-02)
            (432,3.64149E-02)
            (433,3.80957E-02)
            (434,3.98184E-02)
            (435,4.15794E-02)
            (436,4.33710E-02)
            (437,4.51718E-02)
            (438,4.69542E-02)
            (439,4.86872E-02)
            (440,5.03366E-02)
            (441,5.18761E-02)
            (442,5.33222E-02)
            (443,5.47060E-02)
            (444,5.60634E-02)
            (445,5.74339E-02)
            (446,5.88511E-02)
            (447,6.03081E-02)
            (448,6.17864E-02)
            (449,6.32657E-02)
            (450,6.47235E-02)
            (451,6.61475E-02)
            (452,6.75726E-02)
            (453,6.90493E-02)
            (454,7.06328E-02)
            (455,7.23834E-02)
            (456,7.43596E-02)
            (457,7.65938E-02)
            (458,7.91144E-02)
            (459,8.19535E-02)
            (460,8.51482E-02)
            (461,8.87266E-02)
            (462,9.26601E-02)
            (463,9.68972E-02)
            (464,1.01375E-01)
            (465,1.06014E-01)
            (466,1.10738E-01)
            (467,1.15511E-01)
            (468,1.20312E-01)
            (469,1.25116E-01)
            (470,1.29896E-01)
            (471,1.34630E-01)
            (472,1.39331E-01)
            (473,1.44023E-01)
            (474,1.48737E-01)
            (475,1.53507E-01)
            (476,1.58364E-01)
            (477,1.63320E-01)
            (478,1.68376E-01)
            (479,1.73537E-01)
            (480,1.78805E-01)
            (481,1.84182E-01)
            (482,1.89656E-01)
            (483,1.95210E-01)
            (484,2.00826E-01)
            (485,2.06483E-01)
            (486,2.12183E-01)
            (487,2.18028E-01)
            (488,2.24159E-01)
            (489,2.30730E-01)
            (490,2.37916E-01)
            (491,2.45871E-01)
            (492,2.54602E-01)
            (493,2.64076E-01)
            (494,2.74249E-01)
            (495,2.85068E-01)
            (496,2.96484E-01)
            (497,3.08501E-01)
            (498,3.21139E-01)
            (499,3.34418E-01)
            (500,3.48354E-01)
            (501,3.62960E-01)
            (502,3.78228E-01)
            (503,3.94136E-01)
            (504,4.10658E-01)
            (505,4.27760E-01)
            (506,4.45399E-01)
            (507,4.63540E-01)
            (508,4.82138E-01)
            (509,5.01143E-01)
            (510,5.20497E-01)
            (511,5.40139E-01)
            (512,5.60021E-01)
            (513,5.80097E-01)
            (514,6.00317E-01)
            (515,6.20626E-01)
            (516,6.40940E-01)
            (517,6.61077E-01)
            (518,6.80813E-01)
            (519,6.99904E-01)
            (520,7.18089E-01)
            (521,7.35159E-01)
            (522,7.51182E-01)
            (523,7.66314E-01)
            (524,7.80735E-01)
            (525,7.94645E-01)
            (526,8.08207E-01)
            (527,8.21382E-01)
            (528,8.34070E-01)
            (529,8.46171E-01)
            (530,8.57580E-01)
            (531,8.68241E-01)
            (532,8.78306E-01)
            (533,8.87991E-01)
            (534,8.97521E-01)
            (535,9.07135E-01)
            (536,9.16995E-01)
            (537,9.26929E-01)
            (538,9.36673E-01)
            (539,9.45948E-01)
            (540,9.54468E-01)
            (541,9.61983E-01)
            (542,9.68439E-01)
            (543,9.73829E-01)
            (544,9.78152E-01)
            (545,9.81411E-01)
            (546,9.83667E-01)
            (547,9.85208E-01)
            (548,9.86381E-01)
            (549,9.87536E-01)
            (550,9.89023E-01)
            (551,9.91081E-01)
            (552,9.93491E-01)
            (553,9.95917E-01)
            (554,9.98021E-01)
            (555,9.99461E-01)
            (556,9.99993E-01)
            (557,9.99756E-01)
            (558,9.98984E-01)
            (559,9.97912E-01)
            (560,9.96774E-01)
            (561,9.95736E-01)
            (562,9.94711E-01)
            (563,9.93553E-01)
            (564,9.92116E-01)
            (565,9.90255E-01)
            (566,9.87860E-01)
            (567,9.84932E-01)
            (568,9.81504E-01)
            (569,9.77603E-01)
            (570,9.73261E-01)
            (571,9.68476E-01)
            (572,9.63137E-01)
            (573,9.57106E-01)
            (574,9.50254E-01)
            (575,9.42457E-01)
            (576,9.33690E-01)
            (577,9.24289E-01)
            (578,9.14671E-01)
            (579,9.05233E-01)
            (580,8.96361E-01)
            (581,8.88307E-01)
            (582,8.80846E-01)
            (583,8.73645E-01)
            (584,8.66376E-01)
            (585,8.58720E-01)
            (586,8.50430E-01)
            (587,8.41505E-01)
            (588,8.32011E-01)
            (589,8.22015E-01)
            (590,8.11587E-01)
            (591,8.00787E-01)
            (592,7.89652E-01)
            (593,7.78205E-01)
            (594,7.66473E-01)
            (595,7.54479E-01)
            (596,7.42247E-01)
            (597,7.29823E-01)
            (598,7.17252E-01)
            (599,7.04582E-01)
            (600,6.91855E-01)
            (601,6.79101E-01)
            (602,6.66285E-01)
            (603,6.53359E-01)
            (604,6.40281E-01)
            (605,6.27007E-01)
            (606,6.13515E-01)
            (607,5.99849E-01)
            (608,5.86068E-01)
            (609,5.72226E-01)
            (610,5.58375E-01)
            (611,5.44554E-01)
            (612,5.30767E-01)
            (613,5.17013E-01)
            (614,5.03289E-01)
            (615,4.89595E-01)
            (616,4.75944E-01)
            (617,4.62396E-01)
            (618,4.49015E-01)
            (619,4.35862E-01)
            (620,4.22990E-01)
            (621,4.10415E-01)
            (622,3.98036E-01)
            (623,3.85730E-01)
            (624,3.73391E-01)
            (625,3.60924E-01)
            (626,3.48286E-01)
            (627,3.35570E-01)
            (628,3.22896E-01)
            (629,3.10370E-01)
            (630,2.98086E-01)
            (631,2.86116E-01)
            (632,2.74482E-01)
            (633,2.63195E-01)
            (634,2.52263E-01)
            (635,2.41690E-01)
            (636,2.31481E-01)
            (637,2.21638E-01)
            (638,2.12162E-01)
            (639,2.03054E-01)
            (640,1.94312E-01)
            (641,1.85923E-01)
            (642,1.77827E-01)
            (643,1.69965E-01)
            (644,1.62284E-01)
            (645,1.54740E-01)
            (646,1.47308E-01)
            (647,1.40017E-01)
            (648,1.32901E-01)
            (649,1.25991E-01)
            (650,1.19312E-01)
            (651,1.12882E-01)
            (652,1.06711E-01)
            (653,1.00805E-01)
            (654,9.51665E-02)
            (655,8.97959E-02)
            (656,8.46904E-02)
            (657,7.98401E-02)
            (658,7.52337E-02)
            (659,7.08606E-02)
            (660,6.67104E-02)
            (661,6.27736E-02)
            (662,5.90418E-02)
            (663,5.55070E-02)
            (664,5.21614E-02)
            (665,4.89970E-02)
            (666,4.60058E-02)
            (667,4.31788E-02)
            (668,4.05075E-02)
            (669,3.79838E-02)
            (670,3.55998E-02)
            (671,3.33486E-02)
            (672,3.12233E-02)
            (673,2.92178E-02)
            (674,2.73260E-02)
            (675,2.55422E-02)
            (676,2.38612E-02)
            (677,2.22786E-02)
            (678,2.07902E-02)
            (679,1.93919E-02)
            (680,1.80794E-02)
            (681,1.68482E-02)
            (682,1.56919E-02)
            (683,1.46045E-02)
            (684,1.35806E-02)
            (685,1.26157E-02)
            (686,1.17070E-02)
            (687,1.08561E-02)
            (688,1.00648E-02)
            (689,9.33338E-03)
            (690,8.66128E-03)
            (691,8.04605E-03)
            (692,7.48113E-03)
            (693,6.95999E-03)
            (694,6.47707E-03)
            (695,6.02768E-03)
            (696,5.60817E-03)
            (697,5.21669E-03)
            (698,4.85179E-03)
            (699,4.51201E-03)
            (700,4.19594E-03)
        };
    \end{axis}
    \end{tikzpicture}

\end{document} 
5

You can use the point meta key; the x value uses the available x coordinates as point meta data. For further details, refer to pages 157-158 of the pgfplots manual.

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
    \begin{axis}[
        axis x line=bottom,
        axis y line=left,
        ymax=1.1,xmin=390,xmax=710,
xlabel=$x$,ylabel=$\sin x$,
        xlabel=$\lambda$,
        ylabel=$Relative~Sensivity$,
        point meta=x]
    \addplot[smooth,mesh,line width=1.5pt]
        plot coordinates {
            (401,2.85222E-03)
            (402,3.29912E-03)
            (403,3.79747E-03)
            (404,4.35277E-03)
            (405,4.97172E-03)
            (406,5.66101E-03)
            (407,6.42161E-03)
            (408,7.25031E-03)
            (409,8.14017E-03)
            (410,9.07986E-03)
            (411,1.00561E-02)
            (412,1.10646E-02)
            (413,1.21052E-02)
            (414,1.31801E-02)
            (415,1.42938E-02)
            (416,1.54500E-02)
            (417,1.66409E-02)
            (418,1.78530E-02)
            (419,1.90702E-02)
            (420,2.02737E-02)
            (421,2.14481E-02)
            (422,2.26004E-02)
            (423,2.37479E-02)
            (424,2.49125E-02)
            (425,2.61211E-02)
            (426,2.73992E-02)
            (427,2.87499E-02)
            (428,3.01691E-02)
            (429,3.16514E-02)
            (430,3.31904E-02)
            (431,3.47791E-02)
            (432,3.64149E-02)
            (433,3.80957E-02)
            (434,3.98184E-02)
            (435,4.15794E-02)
            (436,4.33710E-02)
            (437,4.51718E-02)
            (438,4.69542E-02)
            (439,4.86872E-02)
            (440,5.03366E-02)
            (441,5.18761E-02)
            (442,5.33222E-02)
            (443,5.47060E-02)
            (444,5.60634E-02)
            (445,5.74339E-02)
            (446,5.88511E-02)
            (447,6.03081E-02)
            (448,6.17864E-02)
            (449,6.32657E-02)
            (450,6.47235E-02)
            (451,6.61475E-02)
            (452,6.75726E-02)
            (453,6.90493E-02)
            (454,7.06328E-02)
            (455,7.23834E-02)
            (456,7.43596E-02)
            (457,7.65938E-02)
            (458,7.91144E-02)
            (459,8.19535E-02)
            (460,8.51482E-02)
            (461,8.87266E-02)
            (462,9.26601E-02)
            (463,9.68972E-02)
            (464,1.01375E-01)
            (465,1.06014E-01)
            (466,1.10738E-01)
            (467,1.15511E-01)
            (468,1.20312E-01)
            (469,1.25116E-01)
            (470,1.29896E-01)
            (471,1.34630E-01)
            (472,1.39331E-01)
            (473,1.44023E-01)
            (474,1.48737E-01)
            (475,1.53507E-01)
            (476,1.58364E-01)
            (477,1.63320E-01)
            (478,1.68376E-01)
            (479,1.73537E-01)
            (480,1.78805E-01)
            (481,1.84182E-01)
            (482,1.89656E-01)
            (483,1.95210E-01)
            (484,2.00826E-01)
            (485,2.06483E-01)
            (486,2.12183E-01)
            (487,2.18028E-01)
            (488,2.24159E-01)
            (489,2.30730E-01)
            (490,2.37916E-01)
            (491,2.45871E-01)
            (492,2.54602E-01)
            (493,2.64076E-01)
            (494,2.74249E-01)
            (495,2.85068E-01)
            (496,2.96484E-01)
            (497,3.08501E-01)
            (498,3.21139E-01)
            (499,3.34418E-01)
            (500,3.48354E-01)
            (501,3.62960E-01)
            (502,3.78228E-01)
            (503,3.94136E-01)
            (504,4.10658E-01)
            (505,4.27760E-01)
            (506,4.45399E-01)
            (507,4.63540E-01)
            (508,4.82138E-01)
            (509,5.01143E-01)
            (510,5.20497E-01)
            (511,5.40139E-01)
            (512,5.60021E-01)
            (513,5.80097E-01)
            (514,6.00317E-01)
            (515,6.20626E-01)
            (516,6.40940E-01)
            (517,6.61077E-01)
            (518,6.80813E-01)
            (519,6.99904E-01)
            (520,7.18089E-01)
            (521,7.35159E-01)
            (522,7.51182E-01)
            (523,7.66314E-01)
            (524,7.80735E-01)
            (525,7.94645E-01)
            (526,8.08207E-01)
            (527,8.21382E-01)
            (528,8.34070E-01)
            (529,8.46171E-01)
            (530,8.57580E-01)
            (531,8.68241E-01)
            (532,8.78306E-01)
            (533,8.87991E-01)
            (534,8.97521E-01)
            (535,9.07135E-01)
            (536,9.16995E-01)
            (537,9.26929E-01)
            (538,9.36673E-01)
            (539,9.45948E-01)
            (540,9.54468E-01)
            (541,9.61983E-01)
            (542,9.68439E-01)
            (543,9.73829E-01)
            (544,9.78152E-01)
            (545,9.81411E-01)
            (546,9.83667E-01)
            (547,9.85208E-01)
            (548,9.86381E-01)
            (549,9.87536E-01)
            (550,9.89023E-01)
            (551,9.91081E-01)
            (552,9.93491E-01)
            (553,9.95917E-01)
            (554,9.98021E-01)
            (555,9.99461E-01)
            (556,9.99993E-01)
            (557,9.99756E-01)
            (558,9.98984E-01)
            (559,9.97912E-01)
            (560,9.96774E-01)
            (561,9.95736E-01)
            (562,9.94711E-01)
            (563,9.93553E-01)
            (564,9.92116E-01)
            (565,9.90255E-01)
            (566,9.87860E-01)
            (567,9.84932E-01)
            (568,9.81504E-01)
            (569,9.77603E-01)
            (570,9.73261E-01)
            (571,9.68476E-01)
            (572,9.63137E-01)
            (573,9.57106E-01)
            (574,9.50254E-01)
            (575,9.42457E-01)
            (576,9.33690E-01)
            (577,9.24289E-01)
            (578,9.14671E-01)
            (579,9.05233E-01)
            (580,8.96361E-01)
            (581,8.88307E-01)
            (582,8.80846E-01)
            (583,8.73645E-01)
            (584,8.66376E-01)
            (585,8.58720E-01)
            (586,8.50430E-01)
            (587,8.41505E-01)
            (588,8.32011E-01)
            (589,8.22015E-01)
            (590,8.11587E-01)
            (591,8.00787E-01)
            (592,7.89652E-01)
            (593,7.78205E-01)
            (594,7.66473E-01)
            (595,7.54479E-01)
            (596,7.42247E-01)
            (597,7.29823E-01)
            (598,7.17252E-01)
            (599,7.04582E-01)
            (600,6.91855E-01)
            (601,6.79101E-01)
            (602,6.66285E-01)
            (603,6.53359E-01)
            (604,6.40281E-01)
            (605,6.27007E-01)
            (606,6.13515E-01)
            (607,5.99849E-01)
            (608,5.86068E-01)
            (609,5.72226E-01)
            (610,5.58375E-01)
            (611,5.44554E-01)
            (612,5.30767E-01)
            (613,5.17013E-01)
            (614,5.03289E-01)
            (615,4.89595E-01)
            (616,4.75944E-01)
            (617,4.62396E-01)
            (618,4.49015E-01)
            (619,4.35862E-01)
            (620,4.22990E-01)
            (621,4.10415E-01)
            (622,3.98036E-01)
            (623,3.85730E-01)
            (624,3.73391E-01)
            (625,3.60924E-01)
            (626,3.48286E-01)
            (627,3.35570E-01)
            (628,3.22896E-01)
            (629,3.10370E-01)
            (630,2.98086E-01)
            (631,2.86116E-01)
            (632,2.74482E-01)
            (633,2.63195E-01)
            (634,2.52263E-01)
            (635,2.41690E-01)
            (636,2.31481E-01)
            (637,2.21638E-01)
            (638,2.12162E-01)
            (639,2.03054E-01)
            (640,1.94312E-01)
            (641,1.85923E-01)
            (642,1.77827E-01)
            (643,1.69965E-01)
            (644,1.62284E-01)
            (645,1.54740E-01)
            (646,1.47308E-01)
            (647,1.40017E-01)
            (648,1.32901E-01)
            (649,1.25991E-01)
            (650,1.19312E-01)
            (651,1.12882E-01)
            (652,1.06711E-01)
            (653,1.00805E-01)
            (654,9.51665E-02)
            (655,8.97959E-02)
            (656,8.46904E-02)
            (657,7.98401E-02)
            (658,7.52337E-02)
            (659,7.08606E-02)
            (660,6.67104E-02)
            (661,6.27736E-02)
            (662,5.90418E-02)
            (663,5.55070E-02)
            (664,5.21614E-02)
            (665,4.89970E-02)
            (666,4.60058E-02)
            (667,4.31788E-02)
            (668,4.05075E-02)
            (669,3.79838E-02)
            (670,3.55998E-02)
            (671,3.33486E-02)
            (672,3.12233E-02)
            (673,2.92178E-02)
            (674,2.73260E-02)
            (675,2.55422E-02)
            (676,2.38612E-02)
            (677,2.22786E-02)
            (678,2.07902E-02)
            (679,1.93919E-02)
            (680,1.80794E-02)
            (681,1.68482E-02)
            (682,1.56919E-02)
            (683,1.46045E-02)
            (684,1.35806E-02)
            (685,1.26157E-02)
            (686,1.17070E-02)
            (687,1.08561E-02)
            (688,1.00648E-02)
            (689,9.33338E-03)
            (690,8.66128E-03)
            (691,8.04605E-03)
            (692,7.48113E-03)
            (693,6.95999E-03)
            (694,6.47707E-03)
            (695,6.02768E-03)
            (696,5.60817E-03)
            (697,5.21669E-03)
            (698,4.85179E-03)
            (699,4.51201E-03)
            (700,4.19594E-03)
        };
    \end{axis}
    \end{tikzpicture}

\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.