I am looking to replicate (Tikz: Draw a RGB cube) with the below cube, shading the top face corners on Overleaf. I will only use a right and left corner for the side faces. I am not sure why shade doesn't understand arguments such as "upper/lower left/right" when I have seen other examples with it used. So unfortunately, I am having only one color showing on the top cube face.
What I have so far:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{3d}
\usetikzlibrary{shadings}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
[cube/.style={very thick,black},
grid/.style={very thin,gray},
axis/.style={->,black,thick}]
\begin{tikzpicture}[scale=0.48,every node/.style={minimum size=1cm},on grid]
\begin{scope}[every node/.append style={yslant=-0.5},yslant=-0.5]
[cube/.style={very thick,black},
axis/.style={->,blue,thick}]
\draw[axis] (5,5,0) -- (-2,-2,0) node[anchor=west]{x};
\shade[right color=red!60, left color=blue!60] (0,0) rectangle +(3,3);
\node at (0.5,2.5) {};
\node at (1.5,2.5) {};
\node at (2.5,2.5) {};
\node at (0.5,1.5) {};
\node at (1.5,1.5) {};
\node at (2.5,1.5) {};
\node at (0.5,0.5) {};
\node at (1.5,0.5) {};
\node at (2.5,0.5) {};
\draw (0,0) grid (3,3);
\end{scope}
\begin{scope}[every node/.append style={yslant=0.5},yslant=0.5]
\draw[axis] (3,0,0) -- (8,-5,0) node[anchor=west]{y};
\shade[right color=green!30,left color=red!30] (3,-3) rectangle +(3,3);
\node at (3.5,-0.5) {};
\node at (4.5,-0.5) {};
\node at (5.5,-0.5) {};
\node at (3.5,-1.5) {};
\node at (4.5,-1.5) {};
\node at (5.5,-1.5) {};
\node at (3.5,-2.5) {};
\node at (4.5,-2.5) {};
\node at (5.5,-2.5) {};
\draw (3,-3) grid (6,0);
\end{scope}
\begin{scope}[every node/.append style={
yslant=0.5,xslant=-1},yslant=0.5,xslant=-1
]
\draw[axis] (3,0,0) -- (8,5,1) node[anchor=west]{z};
% \shade[bottom color=red!30, top color=green!80] (6,3) rectangle +(-3,-3);
\shade[right color=red!80, left color=green!40, top color=red!10, bottom color=green!60] (6,3) rectangle +(-3,-3);
\node at (3.5,2.5) {};
\node at (3.5,1.5) {};
\node at (3.5,0.5) {};
\node at (4.5,2.5) {};
\node at (4.5,1.5) {};
\node at (4.5,0.5) {};
\node at (5.5,2.5) {};
\node at (5.5,1.5) {};
\node at (5.5,0.5) {};
\draw (3,0) grid (6,3);
\end{scope}
\end{tikzpicture}
\end{tikzpicture}
\vspace{-5.5em} % do not remove
\caption{Example caption.}
\label{fig:1}
\end{figure}
\end{document}
I haven't figured out why upper/lower right/left colors for corners do not work with this tikzpicture, however right/left/bottom/top colors do work here. I have added this change to the top cube face in the code here.
\pgfdeclareradialshading
see Section 114.2.2 Radial Shadings in the PGF manual ctan.org/pkg/pgf