ePiX is a collection of batch-oriented utilities for GNU/Linux systems, creates mathematically accurate figures, plots, and movies with output format(PSTricks, tikz, or eepic macros) or as vector (EPS or PDF) image files for use with LaTeX, Unfortunately not available on traditional TeXLive/MiKTeX distro but can be installed on Linux distro (Ubuntu) with sudo apt-get install epix
.
This drawing can be done in ePiX, if you don't mind using an external image file. (The coordinate grids in the compiled PDF aren't as prominent as in the png file below.)
Output

Code
/* -*-ePiX-*- */
#include "epix.h"
using namespace ePiX;
double rad1(1), rad2(0.75);
int N(60); // fineness of plot
// parameter domains for southern/northern portions
domain lower(P(0, 0, -M_PI_2), P(1, 2*M_PI, 0), mesh(N, N, 0.25*N));
domain upper(P(0, M_PI_2, 0), P(1, 2*M_PI, M_PI_2), mesh(N, 0.75*N, 0.25*N));
int main()
{
picture(P(-2,-2), P(2,2), "3 x 3in");
begin();
camera.at(P(4, 2, 2));
fill();
green(0.6);
scenery S(sph, lower.slice1(rad2));
S.add(sph, upper.slice1(rad2));
// add slightly smaller sphere in brighter shade
double scale(0.99);
green(1.2);
S.add(sph, lower.slice1(scale*rad2));
S.add(sph, upper.slice1(scale*rad2));
blue(0.8);
S.add(sph, lower.slice1(rad1));
S.add(sph, upper.slice1(rad1));
blue(1.2);
S.add(sph, lower.slice1(scale*rad1));
S.add(sph, upper.slice1(scale*rad1));
S.draw();
// labels and guide lines
black();
P O(0, 0, 0),
lbl1(sph(1.1*rad1, -M_PI_4, M_PI_4)),
lbl2(sph(1.2*rad1, -M_PI/8, 5*M_PI/12)),
lbl2b(sph(rad2, 0, 5*M_PI/12)),
lbl3(sph(1.2*rad1, M_PI_2, M_PI/3));
label(lbl1, P(-2, 2), "Outer horizon", tl);
label(lbl2, P(-2, 2), "Inner horizon", t);
label(lbl3, P(-2, 2), "Singularity", tr);
pen(White(), 2);
line(lbl2, lbl2b);
line(lbl3, O);
pen(Black(), 1);
line(lbl2, lbl2b);
line(lbl3, O);
red();
dot(P(0, 0, 0));
tikz_format();
end();
}
Compilation methods
a)Running ePiX
via command line: (Needs an TeXLive distro installed along with ePiX
for conversion to pdf)
- Save example code as
sphereblack.xp
and run at command line elaps --pdf sphereblack.xp
generates sphereblack.pdf
directly to include in LaTeX separately.
b)Running ePiX
inside .tex file :
% pdflatex -shell-escape sphere.tex
\documentclass{article}
\immediate\write18{epix sphereblack.xp} % tikz macros due to tikz_format();
\usepackage{tikz}
\begin{document}
\input{sphereblack.eepic} % Input the tikz macros in sphereblack.eepic
\end{document}
For more detailed information on refer ePiX manual
asymptote
missile?