How to make a 2D sphere with decreasing radial gradient

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I'm using this code:



documentclass[a4paper]article
usepackagetikz
usepackagetikz-3dplot

begindocument
tdplotsetmaincoords45135
pgfmathsetmacrorvec.8
pgfmathsetmacrothetavec45
pgfmathsetmacrophivec75

begintikzpicture[scale=9,tdplot_main_coords]
shade[tdplot_screen_coords,ball color = gray!60] (0,0) circle (rvec);
coordinate (O) at (0,0,0);
tdplotsetcoordPrvecthetavecphivec

draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]$x$;
draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]$y$;
draw[thick,->] (0,0,-1) -- (0,0,1) node[anchor=south]$z$;
draw[-stealth,color=black] (O) -- (P) node[midway,above] $r$;
draw[dashed, color=red] (O) -- (Pxy);
draw[dashed, color=red] (P) -- (Pxy);
tdplotdrawarc(O)0.20phivecanchor=north$phi$

tdplotsetthetaplanecoordsphivec
tdplotdrawarc[tdplot_rotated_coords](0,0,0)0.5thetavec90anchor=south west$theta$
tdplotdrawarc[tdplot_rotated_coords](0,0,0)rvec-180180anchor=south west
endtikzpicture
enddocument


which creates:



enter image description here



How to apply decreasing radial gradient?



The intended result would be something like (with the axes, etc remaining visible):



enter image description here










share|improve this question























  • Do you want the axes also to "fade away" or only the sphere?
    – marmot
    3 hours ago










  • Only the sphere.
    – Ziezi
    3 hours ago














up vote
2
down vote

favorite












I'm using this code:



documentclass[a4paper]article
usepackagetikz
usepackagetikz-3dplot

begindocument
tdplotsetmaincoords45135
pgfmathsetmacrorvec.8
pgfmathsetmacrothetavec45
pgfmathsetmacrophivec75

begintikzpicture[scale=9,tdplot_main_coords]
shade[tdplot_screen_coords,ball color = gray!60] (0,0) circle (rvec);
coordinate (O) at (0,0,0);
tdplotsetcoordPrvecthetavecphivec

draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]$x$;
draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]$y$;
draw[thick,->] (0,0,-1) -- (0,0,1) node[anchor=south]$z$;
draw[-stealth,color=black] (O) -- (P) node[midway,above] $r$;
draw[dashed, color=red] (O) -- (Pxy);
draw[dashed, color=red] (P) -- (Pxy);
tdplotdrawarc(O)0.20phivecanchor=north$phi$

tdplotsetthetaplanecoordsphivec
tdplotdrawarc[tdplot_rotated_coords](0,0,0)0.5thetavec90anchor=south west$theta$
tdplotdrawarc[tdplot_rotated_coords](0,0,0)rvec-180180anchor=south west
endtikzpicture
enddocument


which creates:



enter image description here



How to apply decreasing radial gradient?



The intended result would be something like (with the axes, etc remaining visible):



enter image description here










share|improve this question























  • Do you want the axes also to "fade away" or only the sphere?
    – marmot
    3 hours ago










  • Only the sphere.
    – Ziezi
    3 hours ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I'm using this code:



documentclass[a4paper]article
usepackagetikz
usepackagetikz-3dplot

begindocument
tdplotsetmaincoords45135
pgfmathsetmacrorvec.8
pgfmathsetmacrothetavec45
pgfmathsetmacrophivec75

begintikzpicture[scale=9,tdplot_main_coords]
shade[tdplot_screen_coords,ball color = gray!60] (0,0) circle (rvec);
coordinate (O) at (0,0,0);
tdplotsetcoordPrvecthetavecphivec

draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]$x$;
draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]$y$;
draw[thick,->] (0,0,-1) -- (0,0,1) node[anchor=south]$z$;
draw[-stealth,color=black] (O) -- (P) node[midway,above] $r$;
draw[dashed, color=red] (O) -- (Pxy);
draw[dashed, color=red] (P) -- (Pxy);
tdplotdrawarc(O)0.20phivecanchor=north$phi$

tdplotsetthetaplanecoordsphivec
tdplotdrawarc[tdplot_rotated_coords](0,0,0)0.5thetavec90anchor=south west$theta$
tdplotdrawarc[tdplot_rotated_coords](0,0,0)rvec-180180anchor=south west
endtikzpicture
enddocument


which creates:



enter image description here



How to apply decreasing radial gradient?



The intended result would be something like (with the axes, etc remaining visible):



enter image description here










share|improve this question















I'm using this code:



documentclass[a4paper]article
usepackagetikz
usepackagetikz-3dplot

begindocument
tdplotsetmaincoords45135
pgfmathsetmacrorvec.8
pgfmathsetmacrothetavec45
pgfmathsetmacrophivec75

begintikzpicture[scale=9,tdplot_main_coords]
shade[tdplot_screen_coords,ball color = gray!60] (0,0) circle (rvec);
coordinate (O) at (0,0,0);
tdplotsetcoordPrvecthetavecphivec

draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]$x$;
draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]$y$;
draw[thick,->] (0,0,-1) -- (0,0,1) node[anchor=south]$z$;
draw[-stealth,color=black] (O) -- (P) node[midway,above] $r$;
draw[dashed, color=red] (O) -- (Pxy);
draw[dashed, color=red] (P) -- (Pxy);
tdplotdrawarc(O)0.20phivecanchor=north$phi$

tdplotsetthetaplanecoordsphivec
tdplotdrawarc[tdplot_rotated_coords](0,0,0)0.5thetavec90anchor=south west$theta$
tdplotdrawarc[tdplot_rotated_coords](0,0,0)rvec-180180anchor=south west
endtikzpicture
enddocument


which creates:



enter image description here



How to apply decreasing radial gradient?



The intended result would be something like (with the axes, etc remaining visible):



enter image description here







tikz-pgf tikz-3dplot






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago

























asked 4 hours ago









Ziezi

235312




235312











  • Do you want the axes also to "fade away" or only the sphere?
    – marmot
    3 hours ago










  • Only the sphere.
    – Ziezi
    3 hours ago
















  • Do you want the axes also to "fade away" or only the sphere?
    – marmot
    3 hours ago










  • Only the sphere.
    – Ziezi
    3 hours ago















Do you want the axes also to "fade away" or only the sphere?
– marmot
3 hours ago




Do you want the axes also to "fade away" or only the sphere?
– marmot
3 hours ago












Only the sphere.
– Ziezi
3 hours ago




Only the sphere.
– Ziezi
3 hours ago










2 Answers
2






active

oldest

votes

















up vote
3
down vote













If you want only a radial fading, then the example just before section 23.4.2 may be the way to go.



documentclass[a4paper]article
usepackagetikz
usepackagetikz-3dplot
usetikzlibraryfadings
tikzfading[name=fade out,
inner color=transparent!0,
outer color=transparent!100]

begindocument
tdplotsetmaincoords45135
pgfmathsetmacrorvec.8
pgfmathsetmacrothetavec45
pgfmathsetmacrophivec75

begintikzpicture[scale=9,tdplot_main_coords]
fill[tdplot_screen_coords,gray!40!black,%ball color = gray,
path fading=fade out] (0,0) circle (rvec);
coordinate (O) at (0,0,0);
tdplotsetcoordPrvecthetavecphivec

draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]$x$;
draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]$y$;
draw[thick,->] (0,0,-1) -- (0,0,1) node[anchor=south]$z$;
draw[-stealth,color=black] (O) -- (P) node[midway,above] $r$;
draw[dashed, color=red] (O) -- (Pxy);
draw[dashed, color=red] (P) -- (Pxy);
tdplotdrawarc(O)0.20phivecanchor=north$phi$

tdplotsetthetaplanecoordsphivec
tdplotdrawarc[tdplot_rotated_coords](0,0,0)0.5thetavec90anchor=south west$theta$
tdplotdrawarc[tdplot_rotated_coords](0,0,0)rvec-180180anchor=south west
endtikzpicture
enddocument


enter image description here



Another option is to slightly slightly modify the fuzzy circles from the shadings library. (I merely copied and slightly modified the fuzzy circle fading from the library to give you immediate access to the transparency levels at different distances. I am not claiming that my choice is particularly nice, but in the end you need to decide yourself what suits you best. The number 23 does not really represent a percentage, but if you play basketball you may understand why I picked it. ;-)



documentclass[a4paper]article
usepackagetikz
usepackagetikz-3dplot
usetikzlibraryfadings
makeatletter
pgfdeclareradialshadingtikz@lib@fade@circle@23pgfpointorigin
color(0pt)=(pgftransparent!0); color(20bp)=(pgftransparent!50);
color(25bp)=(pgftransparent!92); color(50bp)=(pgftransparent!100)
pgfdeclarefadingcircle with fuzzy edge 23 percentpgfuseshadingtikz@lib@fade@circle@23
makeatother
tikzfading[name=fade out,
inner color=transparent!0,
outer color=transparent!100]

begindocument
tdplotsetmaincoords45135
pgfmathsetmacrorvec.8
pgfmathsetmacrothetavec45
pgfmathsetmacrophivec75

begintikzpicture[scale=9,tdplot_main_coords]
shade[tdplot_screen_coords,ball color=gray!60,
path fading=circle with fuzzy edge 23 percent] (0,0) circle (rvec);
coordinate (O) at (0,0,0);
tdplotsetcoordPrvecthetavecphivec

draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]$x$;
draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]$y$;
draw[thick,->] (0,0,-1) -- (0,0,1) node[anchor=south]$z$;
draw[-stealth,color=black] (O) -- (P) node[midway,above] $r$;
draw[dashed, color=red] (O) -- (Pxy);
draw[dashed, color=red] (P) -- (Pxy);
tdplotdrawarc(O)0.20phivecanchor=north$phi$

tdplotsetthetaplanecoordsphivec
tdplotdrawarc[tdplot_rotated_coords](0,0,0)0.5thetavec90anchor=south west$theta$
tdplotdrawarc[tdplot_rotated_coords](0,0,0)rvec-180180anchor=south west
endtikzpicture
enddocument


enter image description here






share|improve this answer





























    up vote
    1
    down vote













    enter image description here



    replace the shade line with



    `node[circle,shading=radial,outer color=gray!30,inner color=black!80, minimum width=14.5cm];






    share|improve this answer






















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "85"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f452523%2fhow-to-make-a-2d-sphere-with-decreasing-radial-gradient%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      3
      down vote













      If you want only a radial fading, then the example just before section 23.4.2 may be the way to go.



      documentclass[a4paper]article
      usepackagetikz
      usepackagetikz-3dplot
      usetikzlibraryfadings
      tikzfading[name=fade out,
      inner color=transparent!0,
      outer color=transparent!100]

      begindocument
      tdplotsetmaincoords45135
      pgfmathsetmacrorvec.8
      pgfmathsetmacrothetavec45
      pgfmathsetmacrophivec75

      begintikzpicture[scale=9,tdplot_main_coords]
      fill[tdplot_screen_coords,gray!40!black,%ball color = gray,
      path fading=fade out] (0,0) circle (rvec);
      coordinate (O) at (0,0,0);
      tdplotsetcoordPrvecthetavecphivec

      draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]$x$;
      draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]$y$;
      draw[thick,->] (0,0,-1) -- (0,0,1) node[anchor=south]$z$;
      draw[-stealth,color=black] (O) -- (P) node[midway,above] $r$;
      draw[dashed, color=red] (O) -- (Pxy);
      draw[dashed, color=red] (P) -- (Pxy);
      tdplotdrawarc(O)0.20phivecanchor=north$phi$

      tdplotsetthetaplanecoordsphivec
      tdplotdrawarc[tdplot_rotated_coords](0,0,0)0.5thetavec90anchor=south west$theta$
      tdplotdrawarc[tdplot_rotated_coords](0,0,0)rvec-180180anchor=south west
      endtikzpicture
      enddocument


      enter image description here



      Another option is to slightly slightly modify the fuzzy circles from the shadings library. (I merely copied and slightly modified the fuzzy circle fading from the library to give you immediate access to the transparency levels at different distances. I am not claiming that my choice is particularly nice, but in the end you need to decide yourself what suits you best. The number 23 does not really represent a percentage, but if you play basketball you may understand why I picked it. ;-)



      documentclass[a4paper]article
      usepackagetikz
      usepackagetikz-3dplot
      usetikzlibraryfadings
      makeatletter
      pgfdeclareradialshadingtikz@lib@fade@circle@23pgfpointorigin
      color(0pt)=(pgftransparent!0); color(20bp)=(pgftransparent!50);
      color(25bp)=(pgftransparent!92); color(50bp)=(pgftransparent!100)
      pgfdeclarefadingcircle with fuzzy edge 23 percentpgfuseshadingtikz@lib@fade@circle@23
      makeatother
      tikzfading[name=fade out,
      inner color=transparent!0,
      outer color=transparent!100]

      begindocument
      tdplotsetmaincoords45135
      pgfmathsetmacrorvec.8
      pgfmathsetmacrothetavec45
      pgfmathsetmacrophivec75

      begintikzpicture[scale=9,tdplot_main_coords]
      shade[tdplot_screen_coords,ball color=gray!60,
      path fading=circle with fuzzy edge 23 percent] (0,0) circle (rvec);
      coordinate (O) at (0,0,0);
      tdplotsetcoordPrvecthetavecphivec

      draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]$x$;
      draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]$y$;
      draw[thick,->] (0,0,-1) -- (0,0,1) node[anchor=south]$z$;
      draw[-stealth,color=black] (O) -- (P) node[midway,above] $r$;
      draw[dashed, color=red] (O) -- (Pxy);
      draw[dashed, color=red] (P) -- (Pxy);
      tdplotdrawarc(O)0.20phivecanchor=north$phi$

      tdplotsetthetaplanecoordsphivec
      tdplotdrawarc[tdplot_rotated_coords](0,0,0)0.5thetavec90anchor=south west$theta$
      tdplotdrawarc[tdplot_rotated_coords](0,0,0)rvec-180180anchor=south west
      endtikzpicture
      enddocument


      enter image description here






      share|improve this answer


























        up vote
        3
        down vote













        If you want only a radial fading, then the example just before section 23.4.2 may be the way to go.



        documentclass[a4paper]article
        usepackagetikz
        usepackagetikz-3dplot
        usetikzlibraryfadings
        tikzfading[name=fade out,
        inner color=transparent!0,
        outer color=transparent!100]

        begindocument
        tdplotsetmaincoords45135
        pgfmathsetmacrorvec.8
        pgfmathsetmacrothetavec45
        pgfmathsetmacrophivec75

        begintikzpicture[scale=9,tdplot_main_coords]
        fill[tdplot_screen_coords,gray!40!black,%ball color = gray,
        path fading=fade out] (0,0) circle (rvec);
        coordinate (O) at (0,0,0);
        tdplotsetcoordPrvecthetavecphivec

        draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]$x$;
        draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]$y$;
        draw[thick,->] (0,0,-1) -- (0,0,1) node[anchor=south]$z$;
        draw[-stealth,color=black] (O) -- (P) node[midway,above] $r$;
        draw[dashed, color=red] (O) -- (Pxy);
        draw[dashed, color=red] (P) -- (Pxy);
        tdplotdrawarc(O)0.20phivecanchor=north$phi$

        tdplotsetthetaplanecoordsphivec
        tdplotdrawarc[tdplot_rotated_coords](0,0,0)0.5thetavec90anchor=south west$theta$
        tdplotdrawarc[tdplot_rotated_coords](0,0,0)rvec-180180anchor=south west
        endtikzpicture
        enddocument


        enter image description here



        Another option is to slightly slightly modify the fuzzy circles from the shadings library. (I merely copied and slightly modified the fuzzy circle fading from the library to give you immediate access to the transparency levels at different distances. I am not claiming that my choice is particularly nice, but in the end you need to decide yourself what suits you best. The number 23 does not really represent a percentage, but if you play basketball you may understand why I picked it. ;-)



        documentclass[a4paper]article
        usepackagetikz
        usepackagetikz-3dplot
        usetikzlibraryfadings
        makeatletter
        pgfdeclareradialshadingtikz@lib@fade@circle@23pgfpointorigin
        color(0pt)=(pgftransparent!0); color(20bp)=(pgftransparent!50);
        color(25bp)=(pgftransparent!92); color(50bp)=(pgftransparent!100)
        pgfdeclarefadingcircle with fuzzy edge 23 percentpgfuseshadingtikz@lib@fade@circle@23
        makeatother
        tikzfading[name=fade out,
        inner color=transparent!0,
        outer color=transparent!100]

        begindocument
        tdplotsetmaincoords45135
        pgfmathsetmacrorvec.8
        pgfmathsetmacrothetavec45
        pgfmathsetmacrophivec75

        begintikzpicture[scale=9,tdplot_main_coords]
        shade[tdplot_screen_coords,ball color=gray!60,
        path fading=circle with fuzzy edge 23 percent] (0,0) circle (rvec);
        coordinate (O) at (0,0,0);
        tdplotsetcoordPrvecthetavecphivec

        draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]$x$;
        draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]$y$;
        draw[thick,->] (0,0,-1) -- (0,0,1) node[anchor=south]$z$;
        draw[-stealth,color=black] (O) -- (P) node[midway,above] $r$;
        draw[dashed, color=red] (O) -- (Pxy);
        draw[dashed, color=red] (P) -- (Pxy);
        tdplotdrawarc(O)0.20phivecanchor=north$phi$

        tdplotsetthetaplanecoordsphivec
        tdplotdrawarc[tdplot_rotated_coords](0,0,0)0.5thetavec90anchor=south west$theta$
        tdplotdrawarc[tdplot_rotated_coords](0,0,0)rvec-180180anchor=south west
        endtikzpicture
        enddocument


        enter image description here






        share|improve this answer
























          up vote
          3
          down vote










          up vote
          3
          down vote









          If you want only a radial fading, then the example just before section 23.4.2 may be the way to go.



          documentclass[a4paper]article
          usepackagetikz
          usepackagetikz-3dplot
          usetikzlibraryfadings
          tikzfading[name=fade out,
          inner color=transparent!0,
          outer color=transparent!100]

          begindocument
          tdplotsetmaincoords45135
          pgfmathsetmacrorvec.8
          pgfmathsetmacrothetavec45
          pgfmathsetmacrophivec75

          begintikzpicture[scale=9,tdplot_main_coords]
          fill[tdplot_screen_coords,gray!40!black,%ball color = gray,
          path fading=fade out] (0,0) circle (rvec);
          coordinate (O) at (0,0,0);
          tdplotsetcoordPrvecthetavecphivec

          draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]$x$;
          draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]$y$;
          draw[thick,->] (0,0,-1) -- (0,0,1) node[anchor=south]$z$;
          draw[-stealth,color=black] (O) -- (P) node[midway,above] $r$;
          draw[dashed, color=red] (O) -- (Pxy);
          draw[dashed, color=red] (P) -- (Pxy);
          tdplotdrawarc(O)0.20phivecanchor=north$phi$

          tdplotsetthetaplanecoordsphivec
          tdplotdrawarc[tdplot_rotated_coords](0,0,0)0.5thetavec90anchor=south west$theta$
          tdplotdrawarc[tdplot_rotated_coords](0,0,0)rvec-180180anchor=south west
          endtikzpicture
          enddocument


          enter image description here



          Another option is to slightly slightly modify the fuzzy circles from the shadings library. (I merely copied and slightly modified the fuzzy circle fading from the library to give you immediate access to the transparency levels at different distances. I am not claiming that my choice is particularly nice, but in the end you need to decide yourself what suits you best. The number 23 does not really represent a percentage, but if you play basketball you may understand why I picked it. ;-)



          documentclass[a4paper]article
          usepackagetikz
          usepackagetikz-3dplot
          usetikzlibraryfadings
          makeatletter
          pgfdeclareradialshadingtikz@lib@fade@circle@23pgfpointorigin
          color(0pt)=(pgftransparent!0); color(20bp)=(pgftransparent!50);
          color(25bp)=(pgftransparent!92); color(50bp)=(pgftransparent!100)
          pgfdeclarefadingcircle with fuzzy edge 23 percentpgfuseshadingtikz@lib@fade@circle@23
          makeatother
          tikzfading[name=fade out,
          inner color=transparent!0,
          outer color=transparent!100]

          begindocument
          tdplotsetmaincoords45135
          pgfmathsetmacrorvec.8
          pgfmathsetmacrothetavec45
          pgfmathsetmacrophivec75

          begintikzpicture[scale=9,tdplot_main_coords]
          shade[tdplot_screen_coords,ball color=gray!60,
          path fading=circle with fuzzy edge 23 percent] (0,0) circle (rvec);
          coordinate (O) at (0,0,0);
          tdplotsetcoordPrvecthetavecphivec

          draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]$x$;
          draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]$y$;
          draw[thick,->] (0,0,-1) -- (0,0,1) node[anchor=south]$z$;
          draw[-stealth,color=black] (O) -- (P) node[midway,above] $r$;
          draw[dashed, color=red] (O) -- (Pxy);
          draw[dashed, color=red] (P) -- (Pxy);
          tdplotdrawarc(O)0.20phivecanchor=north$phi$

          tdplotsetthetaplanecoordsphivec
          tdplotdrawarc[tdplot_rotated_coords](0,0,0)0.5thetavec90anchor=south west$theta$
          tdplotdrawarc[tdplot_rotated_coords](0,0,0)rvec-180180anchor=south west
          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer














          If you want only a radial fading, then the example just before section 23.4.2 may be the way to go.



          documentclass[a4paper]article
          usepackagetikz
          usepackagetikz-3dplot
          usetikzlibraryfadings
          tikzfading[name=fade out,
          inner color=transparent!0,
          outer color=transparent!100]

          begindocument
          tdplotsetmaincoords45135
          pgfmathsetmacrorvec.8
          pgfmathsetmacrothetavec45
          pgfmathsetmacrophivec75

          begintikzpicture[scale=9,tdplot_main_coords]
          fill[tdplot_screen_coords,gray!40!black,%ball color = gray,
          path fading=fade out] (0,0) circle (rvec);
          coordinate (O) at (0,0,0);
          tdplotsetcoordPrvecthetavecphivec

          draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]$x$;
          draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]$y$;
          draw[thick,->] (0,0,-1) -- (0,0,1) node[anchor=south]$z$;
          draw[-stealth,color=black] (O) -- (P) node[midway,above] $r$;
          draw[dashed, color=red] (O) -- (Pxy);
          draw[dashed, color=red] (P) -- (Pxy);
          tdplotdrawarc(O)0.20phivecanchor=north$phi$

          tdplotsetthetaplanecoordsphivec
          tdplotdrawarc[tdplot_rotated_coords](0,0,0)0.5thetavec90anchor=south west$theta$
          tdplotdrawarc[tdplot_rotated_coords](0,0,0)rvec-180180anchor=south west
          endtikzpicture
          enddocument


          enter image description here



          Another option is to slightly slightly modify the fuzzy circles from the shadings library. (I merely copied and slightly modified the fuzzy circle fading from the library to give you immediate access to the transparency levels at different distances. I am not claiming that my choice is particularly nice, but in the end you need to decide yourself what suits you best. The number 23 does not really represent a percentage, but if you play basketball you may understand why I picked it. ;-)



          documentclass[a4paper]article
          usepackagetikz
          usepackagetikz-3dplot
          usetikzlibraryfadings
          makeatletter
          pgfdeclareradialshadingtikz@lib@fade@circle@23pgfpointorigin
          color(0pt)=(pgftransparent!0); color(20bp)=(pgftransparent!50);
          color(25bp)=(pgftransparent!92); color(50bp)=(pgftransparent!100)
          pgfdeclarefadingcircle with fuzzy edge 23 percentpgfuseshadingtikz@lib@fade@circle@23
          makeatother
          tikzfading[name=fade out,
          inner color=transparent!0,
          outer color=transparent!100]

          begindocument
          tdplotsetmaincoords45135
          pgfmathsetmacrorvec.8
          pgfmathsetmacrothetavec45
          pgfmathsetmacrophivec75

          begintikzpicture[scale=9,tdplot_main_coords]
          shade[tdplot_screen_coords,ball color=gray!60,
          path fading=circle with fuzzy edge 23 percent] (0,0) circle (rvec);
          coordinate (O) at (0,0,0);
          tdplotsetcoordPrvecthetavecphivec

          draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]$x$;
          draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]$y$;
          draw[thick,->] (0,0,-1) -- (0,0,1) node[anchor=south]$z$;
          draw[-stealth,color=black] (O) -- (P) node[midway,above] $r$;
          draw[dashed, color=red] (O) -- (Pxy);
          draw[dashed, color=red] (P) -- (Pxy);
          tdplotdrawarc(O)0.20phivecanchor=north$phi$

          tdplotsetthetaplanecoordsphivec
          tdplotdrawarc[tdplot_rotated_coords](0,0,0)0.5thetavec90anchor=south west$theta$
          tdplotdrawarc[tdplot_rotated_coords](0,0,0)rvec-180180anchor=south west
          endtikzpicture
          enddocument


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 hours ago

























          answered 3 hours ago









          marmot

          60.2k464131




          60.2k464131




















              up vote
              1
              down vote













              enter image description here



              replace the shade line with



              `node[circle,shading=radial,outer color=gray!30,inner color=black!80, minimum width=14.5cm];






              share|improve this answer


























                up vote
                1
                down vote













                enter image description here



                replace the shade line with



                `node[circle,shading=radial,outer color=gray!30,inner color=black!80, minimum width=14.5cm];






                share|improve this answer
























                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  enter image description here



                  replace the shade line with



                  `node[circle,shading=radial,outer color=gray!30,inner color=black!80, minimum width=14.5cm];






                  share|improve this answer














                  enter image description here



                  replace the shade line with



                  `node[circle,shading=radial,outer color=gray!30,inner color=black!80, minimum width=14.5cm];







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 3 hours ago

























                  answered 3 hours ago









                  KJO

                  1608




                  1608



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f452523%2fhow-to-make-a-2d-sphere-with-decreasing-radial-gradient%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      Long meetings (6-7 hours a day): Being “babysat” by supervisor

                      Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                      Confectionery