Skip to content

Instantly share code, notes, and snippets.

@mcnees
Last active September 10, 2017 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcnees/90b12b521af7e362494dbc8c9065dff1 to your computer and use it in GitHub Desktop.
Save mcnees/90b12b521af7e362494dbc8c9065dff1 to your computer and use it in GitHub Desktop.
Shaded hollowed-out sphere
\documentclass[crop=true, border=10pt]{standalone}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
% Some colors I like. The first six are modified versions of colors from
% the Gnome Project "Tango" palette.
\definecolor{plum}{rgb}{0.36078, 0.20784, 0.4}
\definecolor{chameleon}{rgb}{0.30588, 0.60392, 0.023529}
\definecolor{cornflower}{rgb}{0.12549, 0.29020, 0.52941}
\definecolor{scarlet}{rgb}{0.8, 0, 0}
\definecolor{brick}{rgb}{0.64314, 0, 0}
\definecolor{sunrise}{rgb}{0.80784, 0.36078, 0}
\definecolor{lightblue}{rgb}{0.15,0.35,0.75}
\definecolor{carolina}{RGB}{153, 186, 221}
% A custom arrowhead for use on x, y, z axes
\tikzstyle{axisarrow} = [-{Latex[inset=0pt,length=5pt]}]
\begin{document}
\begin{tikzpicture}[scale=1.2]
% Draw the grid.
\draw [cornflower!20,step=0.25,thin] (-3,-3) grid (3,3);
\draw [cornflower!40,step=1.0,thin] (-3,-3) grid (3,3);
% Draw the shaded region between the inner and outer radius
\shade[shading=radial, inner color=white, outer color=orange!60!yellow, opacity=0.90] (0,0) circle (2cm);
% Draw the hollow interior region
\draw[black,fill=white] (0,0) circle (1cm);
% Foreground equator for inner sphere
\draw (-1,0) arc (180:360:1cm and 0.3cm);
% Background equator for inner sphere
\draw[dashed] (-1,0) arc (180:0:1cm and 0.3cm);
% Foreground equator for outer sphere
\draw (-2,0) arc (180:360:2cm and 0.6cm);
% Background equator for outer sphere
\draw[dashed] (-2,0) arc (180:0:2cm and 0.6cm);
% Outline the outer sphere
\draw[black] (0,0) circle (2cm);
% Define coords for endpoint of radial line for outer sphere.
\pgfmathsetmacro\Rox{1.9*cos(50)};
\pgfmathsetmacro\Roy{1.9*sin(50)};
% Draw radial line
\draw [dashed] (0,0)--(\Rox,\Roy);
% Place outer radius label
\node at (\Rox,\Roy) [xshift=0em, yshift=-1.5em] {$R_o$};
% Define coords for endpoint of radial line for inner sphere.
\pgfmathsetmacro\Rix{0.95*cos(140)};
\pgfmathsetmacro\Riy{0.95*sin(140)};
% Draw radial line
\draw [dashed] (0,0)--(\Rix,\Riy);
% Place inner radius label
\node[fill=white,inner sep=0pt] at (\Rix,\Riy) [xshift=0em, yshift=-1em] {$R_i$};
% Node with formula for charge density
\node[inner sep=0pt] at (2.1,-1.8) [xshift=0em, yshift=0em] {$\displaystyle \rho = \frac{k}{r}$};
% Arrow from charge density to region between inner and outer radius
\draw[>={Latex[inset=0pt,length=5pt]}] (1.65,-1.85) edge[out=180,in=290,->] (.8,-1.2);
\end{tikzpicture}
\end{document}
@mcnees
Copy link
Author

mcnees commented Sep 10, 2017

screen shot 2017-09-10 at 3 54 14 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment