I am trying to replace the rainbow in this MWE
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{pgfmath}
\usepackage{amsmath}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[%
%decimalsymbol=comma,
locale=DE,
]{siunitx}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[samples=200, scale=1.15,declare function={
planck(\x,\T)=(374177152466412/\x^5)/(exp(14387.77/(\x*\T))-1);
}]
\begin{axis}[
xmin=0,
xmax=3,
xlabel={$\omega$ [\si{\hertz}]},
ymin=0,
ylabel={$\rho (\omega; T)$ [\si{\joule\per\cubic\meter}]},
ytick=\empty,
no markers,
grid=both,
domain=0.1:3,
]
\addplot+ [forget plot,name path=A] {planck(x,6000)};
\addplot [forget plot,name path=B,samples=2] {0};
%-------------------------------
% add shading code here...
%-------------------------------
\addplot [forget plot,blue] fill between [of=A and B,soft clip={domain=.4:.47}];
\addplot [forget plot,green] fill between [of=A and B,soft clip={domain=.47:.535}];
\addplot [forget plot,yellow] fill between [of=A and B,soft clip={domain=.535:.6}];
\addplot [forget plot,orange] fill between [of=A and B,soft clip={domain=.6:.66}];
\addplot [forget plot,red] fill between [of=A and B,soft clip={domain=.66:.72}];
\pgfplotsinvokeforeach{3000, 4000, 5000, 6000}
{
\addplot {planck(x,#1)};
\addlegendentryexpanded{$T = #1\,\si{\kelvin}$}
}
\end{axis}
\end{tikzpicture}
\end{document}
with the shaded rainbow from this answer
\documentclass{article}
\usepackage[named]{xcolor}
\usepackage{pgffor}
\usepackage{tikz}
\usetikzlibrary{shadings}
\pgfdeclareverticalshading{rainbow}{100bp}
{color(0bp)=(red); color(25bp)=(red); color(35bp)=(yellow);
color(45bp)=(green); color(55bp)=(cyan); color(65bp)=(blue);
color(75bp)=(violet); color(100bp)=(violet)}
\begin{document}
\begin{tikzpicture}
\shade[shading=rainbow,shading angle=270] (0,0) rectangle (5cm,\textheight);
\end{tikzpicture}
\end{document}
How is it possible to "mix" the tikz and pgfplots code?
Thank you very much!