# How to make this figure using pgfplots in Latex?

I try to find a example to make a similar figure equal this example but not found. Thank you

You are asking to draw something of that sort with pgfplots. pgfplots is a good choice because it can color the grid as a function of the 3d coordinates. This is illustrated here

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{tikzpicture}[declare
function={rrr(\x,\y,\z)=sqrt(1+0.1*(\x*\x+\y*\y+\z*\z));}]
\begin{axis}[axis equal,
width=10cm,
height=10cm,
hide axis,
view={15}{8},
scale uniformly strategy=units only,
point meta={symbolic={0.1-0.08*y, % R
1-sqrt(x*x+y*y+z*z)/sqrt(4), % G
sqrt(x*x+y*y+z*z)/sqrt(4)%B
} },
domain = -1:1,
samples y=1,enlargelimits=0.2,
axis background/.style={fill=black}]
% this example burns colors if opacity
% is active in the document.
\foreach \X in {-1,-1/3,1/3,1}
{\foreach \Y in {-1,-1/3,1/3,1}
mesh/color input=explicit mathparse]
({x*rrr(x,\X,\Y)}, {\X*rrr(x,\X,\Y)}, {\Y*rrr(x,\X,\Y)});
mesh/color input=explicit mathparse] ( {\X*rrr(x,\X,\Y)},{x*rrr(x,\X,\Y)},{\Y*rrr(x,\X,\Y)});
mesh/color input=explicit mathparse] ( {\X*rrr(x,\X,\Y)},{\Y*rrr(x,\X,\Y)},{x*rrr(x,\X,\Y)});
samples at={-1,-0.333,0.333,1},
mark options={ball color=white}] ( {\X*rrr(x,\X,\Y)},{x*rrr(x,\X,\Y)},{\Y*rrr(x,\X,\Y)});
}
\temp}}
\end{axis}
\end{tikzpicture}
\end{document} However, pgfplots is not a good choice to draw things in perspective. For this the perspective library is a much better choice. So if you want to have the view as in your screen shot, I'd encourage you to ask a separate question on how to draw this using the perspective library.

Nonetheless, you may fake the perspective, and make the distant layers "fade away". This is achieved by making the (inverse) "metrics" rrr depend on y. (If you plan to play with rrr: note that the RGB functions need to get fed with values between 0 and 1.)

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{tikzpicture}[declare
function={rrr(\x,\y,\z)=sqrt(1+0.1*(\x*\x+\y*\y+\z*\z))/(1+0.1*\y);}]
\begin{axis}[axis equal,
width=10cm,
height=10cm,
hide axis,
clip mode=individual,
view={8}{8},
scale uniformly strategy=units only,
point meta={symbolic={0.1-0.055*y, % R
1-sqrt(x*x+y*y+z*z)/sqrt(5), % G
sqrt(x*x+y*y+z*z)/sqrt(5)%B
} },
domain = -1:1,
samples y=1,enlargelimits=0.2,
axis background/.style={fill=black}]
% this example burns colors if opacity
% is active in the document.
%\clip (current axis.south west) rectangle (current axis.north west);
\foreach \Y in {1,0.333,-0.333,-1}
{\foreach \X in {-1,-0.333,0.333,1}
mesh/color input=explicit mathparse]
({x*rrr(x,\Y,\X)},{\Y*rrr(x,\Y,\X)},{\X*rrr(x,\Y,\X)});
mesh/color input=explicit mathparse] ( {\X*rrr(x,\Y,\X)},{\Y*rrr(x,\Y,\X)},{x*rrr(x,\Y,\X)});
}
\temp}
\foreach \X in {-1,-0.333,0.333,1}
{\edef\temp{%
\noexpand\addplot3 [mark layer=like plot,only marks,mark=ball,scatter,scatter src=1,
samples at={-1,-0.333,0.333,1},mark options={ball color=white}]
({\X*rrr(\X,\Y,x)},{\Y*rrr(\X,\Y,x)},{x*rrr(\X,\Y,x)});
\ifdim\Y pt>-1pt
mesh/color input=explicit mathparse,domain=\Y-0.06:\Y-0.6667]
({\X*rrr(\X,x,1)},
{x*rrr(\X,x,1)},{1*rrr(\X,x,1)});
mesh/color input=explicit mathparse,domain=\Y-0.06:\Y-0.6667]
({\X*rrr(\X,x,0.333)},
{x*rrr(\X,x,0.333)},{0.333*rrr(\X,x,0.333)});
mesh/color input=explicit mathparse,domain=\Y-0.06:\Y-0.6667]
({\X*rrr(\X,x,-0.333)},
{x*rrr(\X,x,-0.333)},{-0.333*rrr(\X,x,-0.333)});
mesh/color input=explicit mathparse,domain=\Y-0.06:\Y-0.6667]
({\X*rrr(\X,x,-1)},
{x*rrr(\X,x,-1)},{-1*rrr(\X,x,-1)});
\noexpand\path[fill=black,fill opacity=0.1] (-1.2,\Y+0.667,-1.2) --
(1.2,\Y+0.667,-1.2) -- (1.2,\Y+0.667,1.2) -- (-1.2,\Y+0.667,1.2)
-- cycle;
\fi
}
\temp}}
\end{axis}
\end{tikzpicture}
\end{document} Or with a blurry light source in the center.

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{tikzpicture}[declare
function={rrr(\x,\y,\z)=sqrt(1+0.1*(\x*\x+\y*\y+\z*\z))/(1+0.1*\y);}]
\begin{axis}[axis equal,
width=10cm,
height=10cm,
hide axis,
clip mode=individual,
view={8}{8},
scale uniformly strategy=units only,
point meta={symbolic={0.1-0.055*y, % R
1-sqrt(x*x+y*y+z*z)/sqrt(5), % G
sqrt(x*x+y*y+z*z)/sqrt(5)%B
} },
domain = -1:1,
samples y=1,enlargelimits=0.2,
axis background/.style={fill=black}]
% this example burns colors if opacity
% is active in the document.
%\clip (current axis.south west) rectangle (current axis.north west);
\foreach \Y in {1,0.333,-0.333,-1}
{\foreach \X in {-1,-0.333,0.333,1}
mesh/color input=explicit mathparse]
({x*rrr(x,\Y,\X)},{\Y*rrr(x,\Y,\X)},{\X*rrr(x,\Y,\X)});
mesh/color input=explicit mathparse] ( {\X*rrr(x,\Y,\X)},{\Y*rrr(x,\Y,\X)},{x*rrr(x,\Y,\X)});
}
\temp}
\foreach \X in {-1,-0.333,0.333,1}
{\edef\temp{%
\noexpand\addplot3 [mark layer=like plot,only marks,mark=ball,scatter,scatter src=1,
samples at={-1,-0.333,0.333,1},mark options={ball color=white}]
({\X*rrr(\X,\Y,x)},{\Y*rrr(\X,\Y,x)},{x*rrr(\X,\Y,x)});
\ifdim\Y pt>-1pt
mesh/color input=explicit mathparse,domain=\Y-0.06:\Y-0.6667]
({\X*rrr(\X,x,1)},
{x*rrr(\X,x,1)},{1*rrr(\X,x,1)});
mesh/color input=explicit mathparse,domain=\Y-0.06:\Y-0.6667]
({\X*rrr(\X,x,0.333)},
{x*rrr(\X,x,0.333)},{0.333*rrr(\X,x,0.333)});
mesh/color input=explicit mathparse,domain=\Y-0.06:\Y-0.6667]
({\X*rrr(\X,x,-0.333)},
{x*rrr(\X,x,-0.333)},{-0.333*rrr(\X,x,-0.333)});
mesh/color input=explicit mathparse,domain=\Y-0.06:\Y-0.6667]
({\X*rrr(\X,x,-1)},
{x*rrr(\X,x,-1)},{-1*rrr(\X,x,-1)});
\noexpand\path[fill=black,fill opacity=0.1] (-1.2,\Y+0.667,-1.2) --
(1.2,\Y+0.667,-1.2) -- (1.2,\Y+0.667,1.2) -- (-1.2,\Y+0.667,1.2)
-- cycle;
\fi
}
\temp}}
\foreach \X in {0.9,0.8,...,0}
{\edef\temp{\noexpand\fill[white,opacity=1-\X,even odd rule] • @Fran One can certainly improve it by e.g. rotating the little spheres (with transform canvas) but as you imply there are tools that are probably more suited for this task. – Schrödinger's cat Nov 6 at 0:11