So I know how to shade a sphere, or even a hemisphere, but I've been unable to shade an octant: octant of a sphere

Drawing the edges of the region to be shaded is straightforward enough, but in order to draw it using arcs it was necessary to rotate the plane in which the arcs are being drawn. I included the whole block of code for completeness, but my question concerns the last few lines.

%define use path
\tikzset{use path/.code=\tikz@addmode{\pgfsyssoftpath@setcurrentpath#1}}

%set the orientation of the coordinate system

%draw the main coordinate system axes
\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,0) -- (0,0,1) node[anchor=south]{$z$};

%set the orientation for the drawing of the first arc

%make path from x=0,y=0,z=r to x=1,y=0,z=0
\path[save path=\ztoxarc,tdplot_rotated_coords] (\radius,0,0) arc (0:90:\radius);

%rotate the plane of drawing and make path from x=0,y=0,z=r to x=0,y=1,z=0
\path[save path=\ztoyarc,tdplot_rotated_coords] (\radius,0,0) arc (0:90:\radius);

%make path from x=r,y=0,z=0 to x=0,y=r,z=0
\path[save path=\xtoyarc] (1,0) arc (0:90:1);

%draw all three arcs
\draw [use path=\xtoyarc \ztoxarc \ztoyarc,dashed];

%draw approximate shading
\shade[ball color=blue!10!white,opacity=0.5] (0,0,1) -- (0,1,0) -- (1,0,0);


Is there any way to combine the last and second to last line, and use the paths I saved in

\xtoyarc \ztoxarc \ztoyarc

along with the \shade command to shade the area between the arcs?

The not entirely shaded octant

Or, failing that, some other straightforward way to do this, which doesn't involve (my backup plan of) doing a bunch of math to figure out a new path parametrization that neatly replaces the coordinates in my current approximation:

\shade[ball color=blue!10!white,opacity=0.5] (0,0,1) -- (0,1,0) -- (1,0,0);

1 Answer 1


I don't know how to concatenate separately defined paths, but you can set rotated coordinates for only part of a path:

\documentclass[tikz, border=5pt]{standalone}
  \draw[->] (0,0,0) -- (2,0,0) node[right] {$x$};
  \draw[->] (0,0,0) -- (0,2,0) node[above] {$y$};
  \draw[->] (0,0,0) -- (0,0,2) node[below left] {$z$};

  \shade[ball color=blue!10!white,opacity=0.5] (1.5,0) arc (0:90:1.5) {[x={(0,0,1)}] arc (90:0:1.5)} {[y={(0,0,1)}] arc (90:0:1.5)};

shaded ball

If you want to keep most of what you've got, it looks like adding use path=\xtoyarc \ztoxarc \ztoyarc to your current \shade command shades the portion of the sphere outside the triangle (with the same ball parameters), so you could just shade it in two portions:

\shade[use path=\xtoyarc \ztoxarc \ztoyarc, ball color=blue!10!white,opacity=0.5] (1,0,0) -- (0,1,0) -- (0,0,1) -- cycle;
\shade[ball color=blue!10!white,opacity=0.5] (1,0,0) -- (0,1,0) -- (0,0,1) -- cycle;

another shaded ball

  • 1
    For me, the dashed lines works with \draw[dashed] (1.5,0) arc (0:90:1.5) {[x={(0,0,1)}] arc (90:0:1.5)} {[y={(0,0,1)}] arc (90:0:1.5)}; ...
    – juanuni
    Jun 13, 2018 at 0:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .