Drawing Lewis Spheres in Tikz

For some reason, I could never get Richard Zach’s Ptolemaic Astronomy diagrams to work correctly, so I set out to write my own macros for TikZ that would allow me to draw Lewis system of sphere diagrams like these:

These aren’t perfect by any means, but they are a decent first start. As far as I can tell, they are built in a similar fashion to Zach’s. The macros are available at the end of this post. Just copy/paste them into your preamble to use.

To get a handle on the syntax, first note that you can specify coordinates in a TikZ drawing using degrees and distance from (0,0). (P.S. Make sure you enclose everything here within the \begin{tikzpicture} \end{tikzpicture} environment!) Thus, we have:

\draw[dotted] (0,0) circle (2cm);
\draw (0,0) to (90:2.5);
\draw (0,0) to (0:2.5);
\draw (0,0) to (180:2.5);
\draw (0,0) to (270:2.5);
\node at (90:3) {90$^\circ$};
\node at (0:3) {0$^\circ$};
\node at (180:3) {180$^\circ$};
\node at (270:3) {270$^\circ$};

The macro \sphere{n} draws a system of spheres with n elements. Thus, \sphere{3} produces:

The way the macros work, you always need to have \sphere{n} before any commands to draw propositions, represented by arcs that intersect the spheres. The syntax for the proposition command is \prop{x}{y}{z} where x is the degree where you want the proposition arc to start, y is the degree where you want it to end, and z is which sphere number you want it to intersect (starting with 0 for the first sphere, 1 for the next sphere, and so on). So, for instance, \prop{65}{30}{0} draws a proposition arc starting at 65 degrees, intersecting the innermost circle, to 30 degrees. Here, I also draw the degree guide-lines so you can see the relative positions of the start and end of the proposition arc:

\sphere{3}
\prop{65}{30}{0}
\draw (0,0) to (90:2.5);
\draw (0,0) to (0:2.5);
\node at (90:3) {90$^\circ$};
\node at (0:3) {0$^\circ$};

Here is another example:

\sphere{4}
\prop{85}{15}{0}
\prop{75}{25}{1}
\prop{65}{35}{2}

There is an optional argument to change the style of the proposition arcs:

\sphere{4}
\prop[dashed]{85}{15}{0}
\prop[thick]{75}{25}{1}
\prop[very thick]{65}{35}{2}

You can also shade propositions that intersect. To do that, I’ve made a different macro: \propshade. This one takes 7 parameters: \propshade[color]{a}{b}{c}{d}{e}{f}{g}

  • color specifies the color of the shaded region; this defaults to gray if not specified.
  • a, b, c are the in, out, and sphere depth coordinates of the first proposition.
  • d, e, f are the in, out, and sphere depth coordinates of the second proposition.
  • g is the outermost sphere you want to shade.

Here is an example:

\sphere{3}
\propshade{75}{25}{0}{50}{0}{1}{1}

And one more:

\sphere{4}
\propshade[blue!30!white]{85}{15}{0}{65}{35}{2}{2}
\prop[thick]{75}{25}{2}

You can add your own labels to the propositions. Here’s an easy way to do so:

\sphere{3}
\propshade{75}{25}{0}{50}{0}{1}{1}
\node at (65:2) {\small{\bf A}};
\node at (40:2) {\small{\bf B}};

The macros are not super flexible, but they should give you at least a few options for drawing some decent-looking Lewis system of sphere diagrams. I hope you find them useful!

Macros

Paste this text in your preamble to get started! Note: this requires TikZ: make sure you also add \usepackage{tikz}. Happy sphering!

%Spheres
\newcommand{\sphere}[1]{
	\foreach \x in {0,1,...,#1}
	\draw[dotted] (0,0) circle (\x*.5 cm);
	\def\sp{#1}
	}
%Proposition
\newcommand{\prop}[4][-]{
	\pgfmathsetmacro\mytemp{((\sp - (#4/2) - 2)*4)/10}
	\draw[#1] (#2:\sp-1) .. controls ({(#2 + #3)/2}: #4/2 - .2 - \mytemp ) .. (#3:\sp-1);	
	}
%Intersective propositions
\newcommand{\propshade}[8][black!20!white]{
	\pgfmathsetmacro\mytemp{((\sp - (#4/2) - 2)*4)/10}
	\pgfmathsetmacro\mytemps{((\sp - (#7/2) - 2)*4)/10}
	\begin{scope}
	\clip (0,0) circle (#8cm);
	\clip (#2:\sp-1) .. controls ({(#2 + #3)/2}: #4/2 - .2 - \mytemp ) .. (#3:\sp-1);
	\clip (#5:\sp-1) .. controls ({(#5 + #6)/2}: #7/2 - .2 - \mytemps ) .. (#6:\sp-1);
	\fill[#1] (-\sp,-\sp) rectangle (\sp,\sp);
	\end{scope}
	\draw (#2:\sp-1) .. controls ({(#2 + #3)/2}: #4/2 - .2 - \mytemp ) .. (#3:\sp-1);
	\draw (#5:\sp-1) .. controls ({(#5 + #6)/2}: #7/2 - .2 - \mytemps ) .. (#6:\sp-1);
	}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s