% !Mode:: "TeX:UTF-8"
\documentclass[tikz]{standalone}
\usepackage{fontspec}
\usepackage{unicode-math}
\usepackage{pgfplots}
\setmainfont{Libertinus Serif}
\setmathfont{Libertinus Math}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture} [
]
\pgfdeclarehorizontalshading{rainbow}{100bp}{
color(0bp)=(violet);
color(30.5bp)=(violet);
color(41bp)=(blue);
color(47bp)=(cyan);
color(51bp)=(green);
color(56.5bp)=(yellow);
color(61bp)=(orange);
color(75bp)=(red);
color(100bp)=(red)
}
\begin{axis} [
width=14cm,
height=8cm,
xlabel={Wavelength (nm)},
ylabel={Normalized absorbance},
xtick={400,450,...,700},
minor x tick num=4,
ytick={0,50,100},
minor y tick num=4,
xmajorgrids=true,
ymajorgrids=true,
yminorgrids=true,
xmin=370,xmax=700,
ymin=0,ymax=100,
legend pos=north east,
clip=false,
every axis plot/.append style={no markers,smooth,tension=0.9,line width=2pt}
]
\addplot+ [blue] table [x=x,y=Blue] {
x Blue
369.69 59.877
379.76 68.998
389.81 77.812
400.00 88.804
409.79 97.001
419.32 100
429.68 96.916
440.17 88.166
450.08 71.953
460.17 51.388
470.09 37.355
480.69 26.279
490.20 18.317
499.87 13.465
510.31 9.236
520.39 5.319
530.73 2.648
};
\addlegendentry{Blue cones};
\node at (axis cs:420,100) [above,text=blue] {420 nm};
\addplot+ [black,dashed] table [x=x,y=Rods] {
x Rods
400.07 32.817
410.12 34.014
419.41 36.614
430.06 40.927
440.38 49.285
449.94 60.445
460.13 72.227
469.85 83.701
480.03 92.533
490.05 98.411
499.53 100
509.52 96.641
519.99 87.124
530.57 73.566
541.38 58.608
550.87 41.942
559.83 28.856
569.69 19.966
580.21 13.411
590.79 7.946
601.08 4.192
};
\addlegendentry{Rods};
\node at (axis cs:498,100) [above,text=black] {498 nm};
\addplot+ [green] table [x=x,y=Green] {
x Green
400.20 35.771
410.24 35.413
419.53 34.903
430.37 34.238
440.40 35.443
450.14 38.049
460.18 42.367
469.90 50.264
480.27 57.695
490.29 68.239
499.57 78.473
509.74 88.242
519.77 95.834
529.84 99.851
540.62 99.045
550.06 93.888
559.47 83.133
568.89 69.112
580.09 53.847
590.42 40.917
600.73 29.231
610.49 20.657
620.26 14.105
630.11 8.954
640.26 5.98
649.49 3.474
};
\addlegendentry{Green cones};
\node at (axis cs:534,100) [above,text=green] {534 nm};
\addplot+ [red] table [x=x,y=Red] {
x Red
400.19 37.171
410.24 35.257
419.53 32.881
430.23 30.04
440.41 28.756
450.15 27.785
460.36 30.391
469.76 34.09
480.49 40.432
490.69 48.02
499.61 56.389
510.20 64.601
520.24 74.837
530.55 83.986
540.63 92.047
550.28 97.154
559.66 99.774
569.28 99.282
579.98 94.594
590.57 85.862
599.77 75.112
610.10 62.027
619.59 47.699
630.65 34.458
639.58 26.199
649.44 17.315
660.71 10.455
668.78 7.016
679.21 3.734
};
\addlegendentry{Red cones};
\node at (axis cs:564,100) [above,text=red] {564 nm};
\shade [shading=rainbow] (370,-30) rectangle (700,-20);
\begin{scope}[font=\small\bfseries,text=white,text height=1.5ex,text depth=0.25ex]
\node at (400,-25) {Violet};
\node at (470,-25) {Blue};
\node at (515,-25) {Cyan};
\node at (545,-25) {Green};
\node at (575,-25) {Yellow};
\node at (620,-25) {Orange};
\node at (680,-25) {Red};
\end{scope}
\end{axis}
\end{tikzpicture}
\end{document}