8

I try to find a example to make a similar figure equal this example but not found. enter image description here

Thank you

20

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.
 \fill[white] (0,0,0) circle[radius=0.1cm];
 \foreach \X in {-1,-1/3,1/3,1}
  {\foreach \Y in {-1,-1/3,1/3,1}
    {\edef\temp{\noexpand\addplot3 [thick,patch, patch type=bilinear,
        mesh/color input=explicit mathparse] 
        ({x*rrr(x,\X,\Y)}, {\X*rrr(x,\X,\Y)}, {\Y*rrr(x,\X,\Y)});
        \noexpand\addplot3 [thick,patch, patch type=bilinear,
        mesh/color input=explicit mathparse] ( {\X*rrr(x,\X,\Y)},{x*rrr(x,\X,\Y)},{\Y*rrr(x,\X,\Y)});
        \noexpand\addplot3 [thick,patch, patch type=bilinear,
        mesh/color input=explicit mathparse] ( {\X*rrr(x,\X,\Y)},{\Y*rrr(x,\X,\Y)},{x*rrr(x,\X,\Y)});
        \noexpand\addplot3 [only marks,mark=ball,scatter,scatter src=1,
        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}

enter image description here

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}
    {\edef\temp{\noexpand\addplot3 [thick,patch, patch type=bilinear,
        mesh/color input=explicit mathparse] 
        ({x*rrr(x,\Y,\X)},{\Y*rrr(x,\Y,\X)},{\X*rrr(x,\Y,\X)});
        \noexpand\addplot3 [thick,patch, patch type=bilinear,
        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       
        \noexpand\addplot3 [thick,patch, patch type=bilinear,
         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\addplot3 [thick,patch, patch type=bilinear,
         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)});
        \noexpand\addplot3 [thick,patch, patch type=bilinear,
         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)});
        \noexpand\addplot3 [thick,patch, patch type=bilinear,
         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}}
 \fill[white] (0,0,0) circle[radius=0.1cm];
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

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}
    {\edef\temp{\noexpand\addplot3 [thick,patch, patch type=bilinear,
        mesh/color input=explicit mathparse] 
        ({x*rrr(x,\Y,\X)},{\Y*rrr(x,\Y,\X)},{\X*rrr(x,\Y,\X)});
        \noexpand\addplot3 [thick,patch, patch type=bilinear,
        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       
        \noexpand\addplot3 [thick,patch, patch type=bilinear,
         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\addplot3 [thick,patch, patch type=bilinear,
         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)});
        \noexpand\addplot3 [thick,patch, patch type=bilinear,
         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)});
        \noexpand\addplot3 [thick,patch, patch type=bilinear,
         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] 
    (0,0,0) circle[radius=0.1cm+\X*0.04cm+0.004cm]
circle[radius=0.1cm+\X*0.04cm];}
   \temp}
 \fill[white] (0,0,0) circle[radius=0.1cm];
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

  • The central dot needs to be made more convincingly spherical... (It's a wonderful answer.) – Anush Nov 4 at 15:08
  • 2
    @Anush I added a more blurry source. The results are somewhat viewer-dependent. – Schrödinger's cat Nov 4 at 15:55
  • Almost seems a raytrancing image. It's a shame that this can't be exported to povray or blender. – Fran Nov 5 at 23:55
  • @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

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.