487

Task

Show off your best scientific illustration !

The main purpose of this question is to share beautiful scientific pictures, preferably with an educational aspect.


Content

Your post must contain a nice picture and the associated code. One can post several pictures, but it must be done in different replies. Of course, it must be done with LaTeX & Friends : the post must start with a short sentence to present the language that you chose (TikZ, Asymptote ...) and the main packages that helped you to make the picture. Don't hesitate to add comments.


Reward

The satisfaction to share without expecting a reward :)

Ok ... 300 points reputation bounty for the best up-voted post until the 15th of Feb.


Related links

I'll contact Texample.net webmaster to see if he is interested to share the best illustrations, with the participant's agreement of course.

Contest: Show Off Your Skillz in TeX & Friends

  • 14
    that's easy :p dx.doi.org/10.1007/978-3-642-36763-2_46 – percusse Feb 5 '14 at 8:43
  • 17
    I'll be glad if Till Tantau himself decide to participate, but that would be a bit unfair ... :) – Thomas Feb 5 '14 at 8:47
  • 6
    I'm surprised this question wasn't closed already by people like this, on the grounds that it's not a question. Or does that apply only to SO, not to tex.SE? – Dan Dascalescu Feb 7 '14 at 0:06
  • 7
    @DanDascalescu: Here on TeX.SX the mood is much more laazyyy. Think alone the existence of a tag big-list (click on it). – Speravir Feb 7 '14 at 0:22
  • 5
    A fantastic proposition... Such "competitions" should be held more often... – Aashutosh Feb 7 '14 at 5:51

64 Answers 64

42

A graphical representation of probabilistic PCA using Sketch, a 3D language that compiles to TikZ :) Made for scribe notes a couple years ago.

pca

def O (0,0,0) % origin
def ax (1,0,0)
def ay (0,1,0)
def az (0,0,1)

def circles {
    def n_circle 50
    repeat { 5, scale(0.7) } 
        sweep[cull=false] 
            {n_circle, rotate(360 / n_circle, (0,0,0), [0,0,1]) }
            (0.25,0,0)
}

def redcircles {
    def n_circle 50
    repeat { 5, scale(0.7) } 
        sweep[cull=false,draw=red] 
            {n_circle, rotate(360 / n_circle, (0,0,0), [0,0,1]) }
            (0.25,0,0)
}

def redsphere {
    def n_circle 20 def n_sphere 20
    sweep[draw=red,fill=none,draw opacity=0.10]
        {n_sphere, rotate(-360/n_sphere, (O), [0,1,0])}
        sweep {n_circle, rotate(180/n_circle, (O), [0,0,1])}
            (0,1,0)
}

def redspheres {
    repeat { 5, scale(0.7) } {redsphere}
}

def pspace_plane {
    %plane
    polygon[style=dashed,fill=none](0,0,1)(1,0,1)(1,0,0)(0,0,0)
    %special |\path #1 node[right] {$\leftarrow \Lambda$};|(1,.5,.5)

    put { scale(2) then rotate(90, (O), [1,0,0]) 
        then translate([0.5,0,0.5]) } {circles}
    special |\path #1 node[above] {$\Lambda Z$};|(.5,.1,.5)

    dots[style=ultra thick](.75,0,.75)
    special |\path #1 node[below] {$\Lambda Z_n$};
        |(.75,-.05,.75)

    put { scale(0.25) then translate([0.75,0,0.75]) } {redspheres}

    dots[fill=red,draw=red,style=ultra thick](.8,.15,.8)
    special |\path #1 node[right,red] {$X_n$};|(.8,.15,.8)
}

def pspace {
    %axes
    line[arrows=<->] (ax)(O)(ay)
    line[arrows=->] (O)(az)

    put { rotate(5, (O), [1,0,1]) then translate([0,0.5,0]) } {pspace_plane}

    special |\node at #1 {$p$-space};| (0.5,-0.25,0)
}

put { scale(1.5) then view((5,5,30)) then perspective(100) } {pspace}

global { language tikz }
  • 1
    First time I hear about this language, thanks ! – Thomas Feb 7 '14 at 6:54
  • Sketch looks just great! I am of limited math knowledge (and OK .. ability ..) but it appear to be concise powerful and approachable - even to the likes of a "me". – javadba Feb 11 '14 at 2:59
39

A picture from my first research project.

This is a graph obtained by studying how a certain monodromy action act on the coefficients of a polynomial potential (of degree 4) of a Schrödinger-type equation.

Each vertex is itself an infinite graph, but it is essentially a tree. The different superscripts determine the type of tree, and the substripts the lengths of the edges in the tree.

The edges represents monodromy actions.

ActionGRaph

\documentclass[a4paper,11pt,dvips]{paper}
\usepackage[all]{xy}
\xyoption{ps}
\xyoption{dvips}

\newcommand{\tta}{\Lambda^A}
\newcommand{\ttr}{\Lambda^R}
\newcommand{\ttl}{\Lambda^L}
\newcommand{\ttm}{\Lambda^M}
\newcommand{\ttc}{\Lambda^C}
\newcommand{\actA}{A}
\newcommand{\actB}{B}
\newcommand{\actE}{E}
\newcommand{\actR}{R}

\begin{document}
\pagestyle{empty}
%1 = ->
%3 = -->
%5 = ..>
\xymatrix @-1pc {
&\ttl_{2,3,2}\ar@/^/@{->}[dr]&&\ttl_{3,2,1}\ar@/^/@{->}[dr]&&\ttl_{4,1,0}\ar@/^/@{->}[dr]&&&&&&&&&&&&&&&&&\\
%
\ttl_{1,3,3}\ar@/^/@{->}[dr]&&\ttl_{2,2,2}\ar@/^/@{->}[dr]\ar@/^/@{..>}[ul]&&\ttl_{3,1,1}\ar@/^/@{->}[dr]\ar@/^/@{..>}[ul] &&\ttl_{4,0,0}\ar@{->}[dd]\ar@/^/@{..>}[ul] \ar@/^/@{-->}[rr] &&\ttc_{4,1,0} \ar@/^/@{..>}[ll]\ar@/^/@{-->}[rr]&& \ttc_{4,2,1}\ar@/^/@{..>}[ll]&&&&&&&&&&\\
%
&\ttl_{1,2,3}\ar@/^/@{->}[dr]\ar@/^/@{..>}[ul]&&\ttl_{2,1,2}\ar@/^/@{->}[dr]\ar@/^/@{..>}[ul] && \ttl_{3,0,1}\ar@{-->}[ur]\ar@{->}[dd]\ar@/^/@{..>}[ul] && &&&&&&&\\
%
\tta_{-2,4}\ar@/^/@{->}[rd]&&\ttl_{1,1,3}\ar@/^/@{->}[dr]\ar@/^/@{..>}[ul] && \ttl_{2,0,2}\ar@{-->}[ur]\ar@{->}[dd]\ar@/^/@{..>}[ul] && \ttm_{3,0,1}\ar@/^/@{-->}[rr]\ar@{..>}[ul]\ar@{->}[dd] &&\ttc_{3,1,1}\ar@/^/@{..>}[ll]\ar@/^/@{-->}[rr]&& \ttc_{3,2,1}\ar@/^/@{..>}[ll]&&&\\
%
& \tta_{-1,4}\ar@/^/@{->}[rd]\ar@/^/@{..>}[ul] && \ttl_{1,0,3}\ar@{-->}[ur]\ar@{->}[dd] \ar@/^/@{..>}[ul] && \ttm_{2,1,1}\ar@{-->}[ur]\ar@{..>}[ul]\ar@{->}[dd] &&&&&&&\\
%Center Below
&&\tta_{0,4}\ar@/^/@{..>}[ul] \ar@{-->}[ur]\ar@/^/@{->}[dl] && \ttm_{1,2,1}\ar@{..>}[ul]\ar@{-->}[ur]\ar@{->}[dd] && \ttm_{2,0,2}\ar@/^/@{-->}[rr]\ar@{..>}[ul]\ar@{->}[dd] &&\ttc_{2,1,2}\ar@/^/@{..>}[ll]\ar@/^/@{-->}[rr]&&\ttc_{2,2,2}\ar@/^/@{..>}[ll]&&&\\
%
&\tta_{1,4}\ar@/^/@{-->}[ur]\ar@/^/@{->}[dl]&&\ttr_{1,0,3}\ar@{..>}[ul]\ar@{-->}[ur] \ar@/^/@{->}[dl]&& \ttm_{1,1,2}\ar@{-->}[ur]\ar@{..>}[ul]\ar@{->}[dd] &&&&&&&&\\
%
\tta_{2,4}\ar@/^/@{-->}[ur]&&\ttr_{1,1,3}\ar@/^/@{-->}[ur]\ar@/^/@{->}[dl]&& \ttr_{2,0,2}\ar@{..>}[ul]\ar@{-->}[ur]\ar@/^/@{->}[dl]&&  \ttm_{1,0,3}\ar@/^/@{-->}[rr]\ar@{..>}[ul]\ar@{->}[dd] &&\ttc_{1,1,3}\ar@/^/@{..>}[ll]\ar@/^/@{-->}[rr] &&\ttc_{1,2,3}\ar@/^/@{..>}[ll]&&&&&&&&\\
%
&\ttr_{1,2,3}\ar@/^/@{-->}[ur]\ar@/^/@{->}[dl] &&\ttr_{2,1,2}\ar@/^/@{-->}[ur]\ar@/^/@{->}[dl]&& \ttr_{3,0,1}\ar@{..>}[ul]\ar@{-->}[ur]\ar@/^/@{->}[dl]&&  &&&&&&&&&&&&\\
%
\ttr_{1,3,3}\ar@/^/@{-->}[ur]&&\ttr_{2,2,2}\ar@/^/@{-->}[ur]\ar@/^/@{->}[dl] &&\ttr_{3,1,1}\ar@/^/@{-->}[ur]\ar@/^/@{->}[dl]&&\ttr_{4,0,0}\ar@{..>}[ul] \ar@/^/@{->}[dl] \ar@/^/@{-->}[rr] &&\ttc_{0,1,4}\ar@/^/@{..>}[ll]\ar@/^/@{-->}[rr]&& \ttc_{0,2,4}\ar@/^/@{..>}[ll]&&&&&&&&&&\\
%
&\ttr_{2,3,2}\ar@/^/@{-->}[ur]&&\ttr_{3,2,1}\ar@/^/@{-->}[ur]&&\ttr_{4,2,0}\ar@/^/@{-->}[ur]&& \\
\actA_1^2: \ar@{->}[r]&&\actA_3^2:\ar@{-->}[r]&&\actA_5^2: \ar@{..>}[r]&&&&&&&&&&&&&&
}
\end{document}
38

Lifting of a random Delaunay triangulation to a hyperbolic paraboloid:

  1. The planar delaunay triangulation was generated using C++ and CGAL
  2. The data was visualized using asymptote

enter image description here

Here is the c++ code:

#include <fstream>
#include <sstream>
#include <vector>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/Triangulation_euclidean_traits_2.h>
#include <CGAL/Delaunay_triangulation_2.h>

using namespace CGAL;

typedef Exact_predicates_inexact_constructions_kernel   K;

typedef Delaunay_triangulation_2<K>                       Triangulation;
typedef Triangulation::Edge_iterator                        Edge_iterator;
typedef Triangulation::Point                                  Point;
typedef Triangulation::Vertex_handle                        Vertex;
typedef Triangulation::Face                                 Face;

typedef Creator_uniform_2<double,Point>         Creator;
typedef std::vector<Point>                        Point_set;
typedef std::vector<std::string>            Edges_str;

int main () {
  int numPts = 50;
  Point_set points;
  points.reserve(numPts);

  Random_points_in_disc_2<Point, Creator> randomGen (1.0 );
  cpp0x::copy_n( randomGen, numPts, std::back_inserter(points));

  Triangulation dt;
  dt.insert(points.begin(),points.end());

  int num_of_edges = 0;

  Edges_str edges_str;
  Edge_iterator eit;
  for (eit = dt.finite_edges_begin(); eit != dt.finite_edges_end(); ++eit)
    {
      ++num_of_edges;
      std::ostringstream strs;
      Triangulation::Face& f = *(eit->first);
      int i = eit->second;
      Vertex vs = f.vertex(f.cw(i));
      Vertex vt = f.vertex(f.ccw(i));
      strs << vs->point().x();
      std::string vsx = strs.str();
      strs.str("");
      strs.clear();
      strs << vs->point().y();
      std::string vsy = strs.str();
      strs.str("");
      strs.clear();
      strs << vt->point().x();
      std::string vtx = strs.str();
      strs.str("");
      strs.clear();
      strs << vt->point().y();
      std::string vty = strs.str();

      std::string curr_edge = "("+vsx+","+vsy+")\n"+"("+vtx+","+vty+")\n";
      edges_str.push_back(curr_edge);
    }

  std::ofstream out("random-delaunay-of-saddle.dat");
  out << num_of_edges << "\n";
  for (Edges_str::iterator it = edges_str.begin(); it != edges_str.end() ; ++it)
    out << *it;
  out.close();
  return 0;
}

that produces the random Delaunay triangulation in the plane. The generated file random-delaunay-of-saddle.dat is used by the following asymptote code,

import graph3;
size(400);

surface operator cast(tube t) {
  return t.s;
}

currentprojection=perspective(0.75,1.2,0.2);
real gridWidth=1.5;
pen  gridPen=blue;

real xy_level=-2.1;

real f (pair p){
  real x = p.x;
  real y = p.y;
  return 0.5*(x^2-y^2);
}

struct Edge {
  pair source; // Source point
  pair target; // Target point
}

struct Edge3D {
  triple source; // Source point
  triple target; // Target point
}

// Read 2D points from file
file fin=input("random-delaunay-of-saddle.dat");
int num_of_edges = fin;
write(num_of_edges);
Edge[] edges;
pair p1,p2;
for (int i=0; i<num_of_edges; ++i){
  p1=fin;
  p2=fin;
  Edge e;
  // Scaling the points, so the surface will be compatible with the non
  // approximated one
  e.source=2*p1;
  e.target=2*p2;
  edges.push(e);
}

Edge3D[] floorEdges,saddleEdges;

for (int i=0 ; i<num_of_edges; ++i){
  pair source=edges[i].source;
  real psx=source.x;
  real psy=source.y;
  pair target=edges[i].target;
  real ptx=target.x;
  real pty=target.y;

  triple Source1=(psx,psy,xy_level);
  triple Target1=(ptx,pty,xy_level);
  Edge3D e1;
  e1.source=Source1;
  e1.target=Target1;
  floorEdges.push(e1);

  triple Source2=(psx,psy,f((source.x,source.y)));
  triple Target2=(ptx,pty,f((target.x,target.y)));
  Edge3D e2;
  e2.source=Source2;
  e2.target=Target2;
  saddleEdges.push(e2);
}

for (int i=0; i<num_of_edges; ++i){
  draw(tube(floorEdges[i].source--floorEdges[i].target,0.02*gridWidth),darkgreen);
  draw(tube(saddleEdges[i].source--saddleEdges[i].target,0.02*gridWidth),darkgreen);
}

real minVal = -2;
real maxVal = -minVal;

surface saddle=surface(f,(minVal,minVal),(maxVal,maxVal),nx=6,Spline);
draw(saddle,gray+opacity(0.75));

surface plane=surface(
                      new triple(pair p) {
                        return (p.x,p.y,xy_level);
                      },(1.2*minVal,1.2*minVal),(1.2*maxVal,1.2*maxVal)
                      );
draw(plane,gray+opacity(0.3));

to generate the image.

35

Here is a plot of the log barrier function B(x1, x2) = -ln x1 - ln x2.

enter image description here

Code (python to generate the lattice):

from numpy import linspace, pi, sin, cos, log
from scipy.optimize import bisect

# Code to generate patches
# (x(r,theta), y(r,theta), z(r,theta)), where
#    x(r,theta) = 1 - r cos(theta), 
#    y(r,theta) = 1 - r sin(theta), 
#    z(r,theta) = -log(x(r,theta)) - log(y(r,theta)).

PATCH = [(0,0), (2,0), (2,2), (0,2), (1,0), (2,1), (1,2), (0,1), (1,1)]
N     = 23
zmax  = 6
zmin  = -log(1)-log(1)

# Determine the value such that z = -log(x(r,theta)) - log(y(r,theta)).
def zinv(theta, z):
  f = lambda r: -log(1 - r*cos(theta)) - log(1 - r*sin(theta)) - z
  maxr = min(1/cos(theta), 1/sin(theta)) - 1e-6
  return bisect(f, 0, maxr)

P = dict()
V = []

# Generate lattice points
for i, theta in enumerate(linspace(1e-6, pi/2-1e-6, N)):
  for j, z in enumerate(linspace(zmin, zmax, N)):
     r = zinv(theta, z)
     x = 1 - r * cos(theta)
     y = 1 - r * sin(theta)
     z = - log(x) - log(y)
     P[i,j] = len(V)
     V.append((x,y,z))

# Write vertices
vfile = open("logbarrier_v.txt", "wt")
for v in V:
  vfile.write("%0.8f %0.8f %0.8f\n" % v)
vfile.close()

# Write patches
pfile = open("logbarrier_p.txt", "wt")
for j in range(0, N-1, 2):
  for i in range(0, N-1, 2):
    for (di, dj) in PATCH:
       pfile.write(str(P[i+di,j+dj]) + " ")
    pfile.write("\n")
pfile.close()

and LaTeX:

\documentclass{standalone}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8} 
\usepgfplotslibrary{patchplots}

\definecolor{plotfill}{RGB}{215,227,244}
\definecolor{plotblue}{RGB}{60,120,200}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=0, xmax=1.2, ymin=0, ymax=1.4, zmin=0, zmax=6, 
             axis y line=center, axis x line=center, axis z line=center,
             view/h=70, xtick={0, 1}, ytick={0}, ztick={0,5}, 
             clip=false, axis on top=false, axis line style=thick, every tick/.style={black, thick}]

\node at (rel axis cs:1,0,0) [above, anchor=north west] {$x_1$};  %sloped like x axis, 
\node at (rel axis cs:0,1,0) [above, anchor=west] {$x_2$};
\node at (rel axis cs:0,0,1) [above, anchor=south] {$B(x_1,x_2)$};


\addplot3 [patch,patch type=biquadratic,shader=faceted interp,samples=5,draw=black, draw opacity=0.8,opacity=0.8,z buffer=sort,
   patch table=logbarrier_p.txt,colormap={custom}{color(0)=(plotfill) color(4)=(plotblue)}]
file {logbarrier_v.txt}; 

\addplot3 [patch,patch type=biquadratic,mesh,draw=black, draw opacity=0.05,z buffer=sort,
   patch table=logbarrier_p.txt]
file {logbarrier_v.txt}; 


\draw [dashed] (axis cs: 1, 0, 0) -- (axis cs: 1, 1, 0);
\draw [dashed, opacity=0.33] (axis cs: 1, 1, 0) -- (axis cs: 0, 1, 0);
\draw [dashed, thick, opacity=0.33] (axis cs: 0, 0.2, 0) -- (axis cs: 0, 1.3, 0);
\draw [thick, opacity=0.33] (axis cs: 0, 1, 0.15) -- (axis cs: 0, 1, -0.15);
\node at (axis cs: 0, 1, 0) [anchor=south, opacity=0.33] {$1$};
\node at (axis cs: 0, 0, 0) [anchor=east] {$\mathbf{0}$};
\end{axis}
\end{tikzpicture}

\end{document}
  • 5
    BTW: For anyone interested, I just learned that you can enable syntax highlighting to non-LaTeX code on stackexchange by adding e.g. <!-- language: lang-python --> in front of python code (see my post). – yyzz Feb 18 '14 at 8:48
35

Here are two example figures produced with the Pre-/Postprocessor gmsh. gmsh has the capability to export geometries, meshes and post processing views (e.g. result of a finite element simulation) to LaTeX using pgfplots. The key feature is that axes, color map and orientation data are automatically exported. It works nicely for three-dimensional views, by automatically creating the mapping of world coordinates (x,y,z) to pixel coordinates (X,Y).

The image in the figures is still a png with a transparent layer, but the axes/labels/captions/annotations are all done with pgfplots.

Disclosure: I added this functionality myself. More info/demos.

View on a mesh of a ring shaped pipe.

Three quarters of a ring shaped pipe

\begin{tikzpicture}
\begin{axis}[
    width=.5\linewidth, % set figure width here
    enlargelimits=false, % tight axis, use xmin=<val>, xmax=<val> for custom bounding box
    grid=both,
    minor tick num=1,
    3d box,
    xlabel={x}, %
    ylabel={y},
    zlabel={z},
    zlabel style={rotate=90},
    ]
      \addplot3[surf] graphics[debug=false,%=visual,
        points={%
        (-12,-2,-12) => (750,595-341)
        (-12,8,-12) => (743,595-23)
        (-12,8,12) => (16,595-98)
        (12,-2,-12) => (1039,595-520)
        (12,-2,12)%  => (308,595-595)
        (12,8,-12)%  => (1038,595-202)
        (12,8,12)%  => (306,595-277)
        (-12,-2,12)%  => (18,595-415)
        }]
        {test-extr2.png};
\end{axis}
\end{tikzpicture}%

Example of a post processing view with automatically exported axes and color bar.

The dashed line and the dummy legend was added manually to demonstrate that drawing on top of the figure is easy. Everything else was created automatically.

Post processing view

\pgfplotsset{
colormap={gmshcolormap}{% note: Only needed once if colorbars do not change
rgb255=(0,12,92) rgb255=(0,7,98) rgb255=(9,3,103) rgb255=(19,0,107) rgb255=(30,0,110) rgb255=(40,0,112) rgb255=(50,0,113) rgb255=(60,0,114) rgb255=(70,0,114) rgb255=(79,0,114) rgb255=(88,0,113) rgb255=(97,0,111) rgb255=(105,1,109) rgb255=(114,4,107) rgb255=(122,8,104) rgb255=(130,12,100) rgb255=(137,16,97) rgb255=(145,21,93) rgb255=(152,26,88) rgb255=(159,31,84) rgb255=(166,37,79) rgb255=(174,45,73) rgb255=(180,51,68) rgb255=(186,58,63) rgb255=(192,65,58) rgb255=(198,72,53) rgb255=(203,80,48) rgb255=(208,87,43) rgb255=(213,95,38) rgb255=(218,102,33) rgb255=(222,110,29) rgb255=(226,118,25) rgb255=(230,126,21) rgb255=(234,133,17) rgb255=(237,141,14) rgb255=(241,149,11) rgb255=(244,157,9) rgb255=(246,164,7) rgb255=(249,172,6) rgb255=(251,179,5) rgb255=(254,186,5) rgb255=(255,193,5) rgb255=(255,202,7) rgb255=(255,208,9) rgb255=(255,214,11) rgb255=(255,220,15) rgb255=(255,226,19) rgb255=(255,231,25) rgb255=(255,236,31) rgb255=(255,240,38) rgb255=(255,244,46) rgb255=(255,248,55) rgb255=(255,251,66) rgb255=(255,254,77) rgb255=(255,255,90) rgb255=(255,255,103) rgb255=(255,255,118) rgb255=(255,255,134) rgb255=(254,255,152) rgb255=(252,255,171) rgb255=(249,255,191) rgb255=(247,254,213) rgb255=(244,251,236) rgb255=(241,247,255) }
}%
\begin{tikzpicture}
\begin{axis}[
    width=.5\linewidth, % set figure width here
    enlargelimits=false, % tight axis, use xmin=<val>, xmax=<val> for custom bounding box
    xlabel={x}, % if you rotated your view, adjust these labels!
    ylabel={y},
    scale only axis,
    axis equal image, % use png aspect ratio
    axis on top,
    title={Electric Field Intensity / (V/m)},
    colorbar,
    scaled ticks=false,
    colormap name=gmshcolormap,
    colorbar right, %or left...
    colorbar style={
            %width=0.5cm, % adjust width of colorbar
            %height=6cm,% adjust height of colorbar,
    }]
      % a dummy plot for the colorbar (invisible):
      \addplot[point meta min=0.000000, point meta max=359, update limits=false, 
            draw=none, colorbar source, forget plot]
      coordinates{(1,1)};
      \addplot[surf,point meta min=0, point meta max=359] 
            graphics[xmin=0, xmax=0.05, ymin=0, ymax=0.05]
        {cycl.png};
        \label{pgfplots:surf}
      \addlegendentry{foo $\Phi_x^2$}
      \addplot[black,densely dashed,ultra thick,
         update limits=false,domain=0:0.05,samples=100] {-0.5*x+0.025+0.01*sin(10000*x)};
        \label{pgfplots:dummy}
      \addlegendentry{bar $|\langle \varphi \rangle^2|_\infty$}
\end{axis}
\end{tikzpicture}%
  • Very, very nice! This will come in handy for me in the future. Excellent work. – Paul Gessler Apr 25 '14 at 12:36
33

Decimation

This diagram shows a decimation process in a database. The first level shows random samples, and subsequent levels calculate the min, mean, and max of groups of four entries from each previous level.

The cool thing about this is that all of the math, including the random number generation, is done directly in TikZ. Since the actual numbers didn't matter, I was able to choose a random seed that made the result look best.

\documentclass[tikz]{standalone}
\usepackage{fullpage}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{etoolbox}

\usetikzlibrary{decorations}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}

\newtoggle{quickdecim}
%\toggletrue{quickdecim} % Uncomment this to render more quickly (non-random)

\begin{document}

\begin{tikzpicture}[,
  ]
  \def\levels{4} % 2, 3, or 4
  \pgfmathtruncatemacro{\blocks}{4^(\levels-1)}
  \def\maxrand{99}
  \def\xoffset{1.1}
  \def\yoffset{2.6}
  \pgfmathsetseed{31337}
  \pgfmathsetmacro{\totalwidth}{10}
  \pgfmathsetmacro{\levelheight}{2.4}
  \pgfmathsetmacro{\sampleheight}{0.55}

  \definecolor{lowcolor} {rgb}{0.6,0.6,1}
  \definecolor{highcolor}{rgb}{0.6,1,0.6}

  \tikzstyle{Sample} = [
  draw, anchor=west,
  inner sep=0,
  outer sep=0,
  minimum height=\sampleheight * 1cm,
  font=\small,
  text=black,
  ]

  % make random numbers
  \pgfmathtruncatemacro{\runningrandarray}{random(\maxrand)}
  \foreach \x[count=\xi from 1] in {2,...,\blocks}{
    \let\temprand\runningrandarray
    \pgfmathtruncatemacro{\tempres}{random(\maxrand)}
    \xdef\runningrandarray{\temprand,\tempres}
  }
  \xdef\randarray{{\runningrandarray}}

  % boxes
  \foreach \level in {1,...,\levels} {
    \coordinate (level\level sample0) at
    (\xoffset - \totalwidth / 2,
    \yoffset + \levelheight - \levelheight * \level);
    \pgfmathsetmacro{\avgblocks}{4^(\level-1)}
    \pgfmathsetmacro{\levelblocks}{\blocks / \avgblocks}
    \pgfmathsetmacro{\samplewidth}{\totalwidth/\levelblocks}

    \foreach \i in {1,...,\levelblocks} {
      \iftoggle{quickdecim}{
        % can do this instead of using real samples, for speed
        \xdef\smin{5}
        \xdef\smean{50}
        \xdef\smax{95}
      }{
        % calculate sample values from the randarray
        \pgfmathsetmacro{\smin}{100}
        \pgfmathsetmacro{\smax}{0}
        \pgfmathsetmacro{\samplesum}{0}
        \pgfmathsetmacro{\countfrom}{(\i - 1) * \avgblocks}
        \pgfmathsetmacro{\countto}{\countfrom + \avgblocks - 1}
        \foreach \j in {\countfrom,...,\countto} {
          \pgfmathsetmacro{\tmp}{\samplesum + \randarray[\j] / \avgblocks}
          \xdef\samplesum{\tmp}
          \pgfmathtruncatemacro{\tmp}{min(\smin, \randarray[\j])}
          \xdef\smin{\tmp}
          \pgfmathtruncatemacro{\tmp}{max(\smax, \randarray[\j])}
          \xdef\smax{\tmp}
        };
        \pgfmathtruncatemacro{\tmp}{\samplesum}
        \xdef\smean{\tmp}
      }
      \pgfmathtruncatemacro{\cmin}{(\smin - 1) / (\maxrand - 1) * 100}
      \pgfmathtruncatemacro{\cmean}{(\smean - 1) / (\maxrand - 1) * 100}
      \pgfmathtruncatemacro{\cmax}{(\smax - 1) / (\maxrand - 1) * 100}
      \pgfmathtruncatemacro{\prev}{\i-1}

      \ifnumequal{\level}{1}{
        \node[Sample, xshift=\samplewidth * \prev cm, draw,
        yshift=\sampleheight * -2cm,
        minimum width=\samplewidth cm,
        fill=highcolor!\cmean!lowcolor]
        (level\level samplemax\i) at (level\level sample0) {};
        \coordinate (level\level samplemin\i) at (level\level samplemax\i);
        \coordinate (level\level samplemean\i) at (level\level samplemax\i);
      }{
        \node[Sample, xshift=\samplewidth * \prev cm, draw,
        yshift=\sampleheight * 0cm,
        minimum width=\samplewidth cm,
        fill=highcolor!\cmin!lowcolor]
        (level\level samplemin\i) at (level\level sample0) {\smin};

        \node[Sample, xshift=\samplewidth * \prev cm, draw,
        yshift=\sampleheight * -1cm,
        minimum width=\samplewidth cm,
        fill=highcolor!\cmean!lowcolor]
        (level\level samplemean\i) at (level\level sample0) {\smean};

        \node[Sample, xshift=\samplewidth * \prev cm, draw,
        yshift=\sampleheight * -2cm,
        minimum width=\samplewidth cm,
        fill=highcolor!\cmax!lowcolor]
        (level\level samplemax\i) at (level\level sample0) {\smax};
      }
    };

    \coordinate (level\level sampleminlabel)
    at (level\level samplemin\levelblocks);
    \coordinate (level\level samplemeanlabel)
    at (level\level samplemean\levelblocks);
    \coordinate (level\level samplemaxlabel)
    at (level\level samplemax\levelblocks);
  };

  % arrows
  \foreach \next in {2,...,\levels} {
    \pgfmathtruncatemacro{\level}{\next-1}
    \pgfmathsetmacro{\amplitude}{3pt * \level + 1.5pt}
    \pgfmathsetmacro{\thislevelblocks}{\blocks / (4^(\level-1))}
    \pgfmathsetmacro{\nextlevelblocks}{\blocks / (4^(\level))}
    \foreach \block in {1,...,\nextlevelblocks} {
      \pgfmathtruncatemacro{\a}{4*(\block-1)+1}
      \pgfmathtruncatemacro{\b}{4*(\block-1)+4}
      \pgfmathtruncatemacro{\c}{4*(\block-1)+2}
      \draw [thick, decorate, decoration={brace, amplitude=\amplitude, mirror}]
      ([xshift=0.5pt]level\level samplemax\a.south west) --
      ([xshift=-0.5pt]level\level samplemax\b.south east);
      \draw[thick, -stealth]
      ([yshift=-\amplitude]level\level samplemax\c.south east) --
      (level\next samplemin\block .north);
    };
  };

  % text
  \foreach \level in {1,...,\levels} {
    \pgfmathtruncatemacro{\decim}{(4^(\level - 1))}
    % Level N
    \node[xshift=-2.5cm, yshift=6pt, anchor=west] (foo) at
    ($(level\level sample0 |- level\level samplemean1)$)
    {Level \level};
    % Samples
    \node[anchor=north, inner sep=0, font=\footnotesize] at (foo.south)
    {\ifnumequal{\level}{1}{(${\color{red}N}$ values)}
      {($3\cdot {\color{red}N / \decim}$ values)}};
  };

  \begin{scope}[anchor=west, inner sep=0, font=\footnotesize\itshape,
    text depth=0ex, text height=1.1ex, draw]
    \foreach \level in {2,...,\levels} {
      \node[xshift=3pt] at (level\level sampleminlabel) { min };
      \node[xshift=3pt] at (level\level samplemeanlabel) { mean };
      \node[xshift=3pt] at (level\level samplemaxlabel) { max };
    };
  \end{scope}

  \node[yshift=-0.8cm] at (foo.south) { $\vdots$ };

\end{tikzpicture}

\end{document}
33

Here are some of the pictures from my master thesis. The topic were transmission and reflexion of (sound) waves at the open end of a tube.

All images are made with TikZ and pgfplots. Many thanks to Christian Feuersänger for showing how to do the wave shadings!

All images are shown in one document, which I split in parts for this answer. To compile it on your machine you must put all fragments in one document; and gnuplotis required, too.

% !TeX encoding = utf8
\documentclass[
   11pt,cmyk,
   multi={tikzpicture},
   border=10mm,
]{standalone}


% General packages
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{helvet}
\usepackage[garamond]{mathdesign}
\usepackage{mathtools}

% Colors
\usepackage{xcolor}
   \definecolor{spot}{cmyk}{1,0.20,0,0}
   \colorlet{gray}{black!60}
   \colorlet{wave}{spot}

% Load TikZ and libraries
\usepackage{tikz}
\usetikzlibrary{calc,positioning,decorations.pathmorphing,%
   arrows.meta,backgrounds}
% Define TikZ styles etc.
\tikzset{
   every plot/.style={
      prefix=plots/,
      samples=200,
   },
   every node/.style={
      font=\footnotesize,
   },
   line width=1pt,
   shorten/.style={
      shorten >=#1,
      shorten <=#1,
   },
   >=Triangle[],
   axis/.style={-Stealth[]},
   tick/.style={
      axis,
      shorten <=-0.5\pgflinewidth,
      shorten >=-0.5\pgflinewidth,
   },
}

% Load and configure pgfplots
\usepackage{pgfplots}
   \usepgfplotslibrary{polar}
   \pgfplotsset{
      compat=1.11,
      wave axis/.style={
         view={0}{90},
         hide axis,
         colormap={custom}{color=(white) color=(wave)},
         trig format plots=rad,
         trig format=rad,
         x=1cm,
         y=1cm,
         z=0cm,
         anchor=origin,
      },
      wave plot/.style={
         samples=200,
         samples y=2,
         surf,shader=interp,
      },
      polar wave plot/.style={
         data cs=polar,
         domain=0:2*pi,
         samples y=100,
         surf,shader=interp,
      },
   }

% Macro for subfigure captions
\newcommand{\subfig}[1]{\textbf{\textsf{#1)}}~}

\begin{document}

Modes of a wave in a tube

modes

\begin{tikzpicture}[
   tube/.style={ultra thick,black},
   wave/.style={thick,gray},
]
   % define variables
   %% tube size
   \def\H{.9}
   \def\L{5.5}
   %% distances
   \def\A{0.3}
   \def\B{0.5}
   %% wave's amplitude
   \pgfmathsetmacro\a{0.35}
   % both ends open or closed
   \foreach \n in {1,2,3,4,5} {
      \begin{scope}[shift={(0,-\n*\H-\n*\A)}]
         % closed ends
         %% wave
         \begin{scope}
            % air pressure
            \begin{axis}[wave axis]
               \addplot3[wave plot,domain=0:\L,domain y=-\H/2:\H/2] {abs(sin(pi/\L * \n * x))};
%               \addplot[domain=0:\L,samples=100] function {abs(sin(pi/\L * \n * x))};
            \end{axis}
            % wave form
            \draw [wave]
               plot [id=moden-gg-1-\n, domain=0:\L] function {\a * sin(pi/\L * \n * x)}
               plot [id=moden-gg-2-\n, domain=0:\L] function {-\a * sin(pi/\L * \n * x)};
         \end{scope}
         %% tube
         \draw [tube] (\L,-\H/2) -| (0,\H/2) -- (\L,\H/2) -- cycle;
         %% coordinates for later use
         \coordinate (GG-\n) at (0,0);
         \coordinate (B1) at (0,-\H/2);
         % open ends
         \begin{scope}[shift={(\L+\B,0)}]
            %% wave
            \begin{scope}
               % air pressure
               \begin{axis}[wave axis]
                  \addplot3[wave plot,domain=0:\L,domain y=-\H/2:\H/2] {abs(cos(pi/\L * \n * x))};
%                  \addplot[domain=0:\L,samples=100] function {abs(cos(pi/\L * \n * x))};
               \end{axis}
               % wave
               \draw [wave]
                  plot [id=moden-oo-1-\n, domain=0:\L] function {\a * cos(pi/\L * \n * x)}
                  plot [id=moden-oo-2-\n, domain=0:\L] function {-\a * cos(pi/\L * \n * x)};
            \end{scope}
            %% tube
            \draw [tube] (0,-\H/2) -- (\L,-\H/2) (0,\H/2) -- (\L,\H/2);
            %% coordinates
            \coordinate (B2) at (0,-\H/2);
         \end{scope}
      \end{scope}
   }
   \foreach \n in {1,3,5} {
      \begin{scope}[shift={(0,-\n*\H-\n*\A)}]
         % one end open, one closed
         \begin{scope}[shift={(2*\L+2*\B,0)}]
            %% wave
            \begin{scope}
               % air pressure
               \begin{axis}[wave axis]
                  \addplot3[wave plot,domain=0:\L,domain y=-\H/2:\H/2] {abs(sin(pi/\L * (\n-0.5) * x))};
%                  \addplot[domain=0:\L,samples=100] function {abs(sin(pi/\L * (\n-0.5) * x))};
               \end{axis}
               % wave
               \draw [wave]
                  plot [id=moden-go-1-\n, domain=0:\L] function {\a * sin(pi/\L * (\n-0.5) * x)}
                  plot [id=moden-go-2-\n, domain=0:\L] function {-\a * sin(pi/\L * (\n-0.5) * x)};
            \end{scope}
            %% tube
            \draw [tube] (\L,-\H/2) -| (0,\H/2) -- (\L,\H/2);
            %% coordinates
            \coordinate (B3) at (0,-\H/2);
         \end{scope}
      \end{scope}
   }
   % captions/text
   \foreach \n in {1,2,3,4,5} {
      \node at (GG-\n) [rotate=90,left=4pt,anchor=south,inner sep=0pt] {$n=\n$};
   }
   \node  at (B1) [below right=1.5mm and 0mm,inner sep=0pt] {\subfig{a}{closed/closed}};
   \node  at (B2) [below right=1.5mm and 0mm,inner sep=0pt] {\subfig{b}{open/open}};
   \node  at (B3) [below right=1.5mm and 0mm,inner sep=0pt] {\subfig{c}{closed/open}};
\end{tikzpicture}

Wave moves through five points (particles)

moving wave

\begin{tikzpicture}
   % define variables
   %% wave
   \pgfmathsetmacro\T{9}
   \pgfmathsetmacro\A{1.75}
   %% oscillations
   \pgfmathsetmacro\Ti{1.5}
   \pgfmathsetmacro\Ai{0.6}
   \pgfmathsetmacro\yMax{1}
   \pgfmathsetmacro\xMax{2*\Ti+0.3}
   \pgfmathsetmacro\D{2*\Ti+0.2}
   \coordinate (S) at (0,-2.7);
   % wave
   %% axis
   \draw [axis] (0,-2) -- (0,2.6) node [left] {$z(x,0)$};
   \draw [axis] (0,0) -- (10,0) node [below] {$x$};
   \draw [tick, |-] (0,\A) node [left] {$z_\text{m}$} -- (0,0);
   %% wave langth
   \draw [|-|] (0,2.2) -- ++ (\T,0) node [midway,above] {$\lambda$};
   %% wave form
   \draw [ultra thick, gray] plot [id=welle, domain=-\yMax-0.1:\T+\yMax]
      function {\A*sin(2*pi/\T*x)};
   \pgfmathsetmacro\X{0.425*\T}
   \pgfmathsetmacro\Y{\A*sin(2*pi/\T*\X r)}
   \draw [gray] (\X,\Y) -- ++(35:0.7) node [right,align=left]
      {\textbf{snapshot} of wave\\ at time $t=0$};;
   %% oscillating points
   \coordinate (1) at (0.00*\T,0);
   \coordinate (2) at (0.25*\T,\A);
   \coordinate (3) at (0.50*\T,0);
   \coordinate (4) at (0.75*\T,-\A);
   \coordinate (5) at (1.00*\T,0);
   \coordinate (6) at (1.25*\T,\A);
   \foreach \n in {1,2,3,4,5} {
      \node (n\n) at (\n) [
         circle,
         font=\sffamily\scriptsize,
         spot,
         draw, ultra thick,
         fill=white,
         inner sep=0pt,
         minimum size=3mm,
         outer sep=1mm,
      ] {\n};
   }
   %% movment of points
   \draw [spot,thick,->] (n1) -- ++(0,-0.5*\A);
   \draw [spot,thick,->] (n2) -- ++(0,-0.5*\A);
   \draw [spot,thick,->] (n3) -- ++(0,0.5*\A);
   \draw [spot,thick,->] (n4) -- ++(0,0.5*\A);
   \draw [spot,thick,->] (n5) -- ++(0,-0.5*\A);
   % oscillations
   \begin{scope}[shift={($(1)+(S)$)}, rotate=-90]
      %% axis
      \draw [axis] (0,-\yMax) -- (0,\yMax) node [above,midway] {$z_1(t)$};
      \draw [axis] (0,0) -- (\xMax,0) node [right] {$t$};
      %% sine form
      \draw [thick, spot] plot [id=welle-schwingung-1, domain=0:\D]
         function {-\Ai*sin(2*pi/\Ti*x))};
      %% ponts
      \node (n) at (0,0) [
         circle,
         font=\sffamily\tiny,
         spot,
         draw, thick,
         fill=white,
         inner sep=0pt,
         minimum size=2mm,
         outer sep=0.5mm,
      ] {1};
      %% movment
      \draw [spot,thick,-{Triangle[scale=0.7]}] (n) -- ++(0,-\Ai);
      %% origin coordinate for later use
      \coordinate (U1) at (0,0);
      %% root coordinate for later use
      \coordinate (N1) at (3*\Ti/4,0);
   \end{scope}
   \begin{scope}[shift={($(2)+(S)+(0,-\A)$)}, rotate=-90]
      \draw [axis] (0,-\yMax) -- (0,\yMax) node [above,midway] {$z_2(t)$};
      \draw [axis] (0,0) -- (\xMax,0) node [right] {$t$};
      \draw [thick, spot] plot [id=welle-schwingung-2, domain=0:\D]
         function {\Ai*sin(2*pi/\Ti*x+pi/2)};
      \node (n) at (0,\Ai) [
         circle,
         font=\sffamily\tiny,
         spot,
         draw, thick,
         fill=white,
         inner sep=0pt,
         minimum size=2mm,
         outer sep=0.5mm,
      ] {2};
      \draw [spot,thick,-{Triangle[scale=0.7]}] (n) -- ++(0,-\Ai);
      \coordinate (N2) at (4*\Ti/4,0);
   \end{scope}
   \begin{scope}[shift={($(3)+(S)$)}, rotate=-90]
      \draw [axis] (0,-\yMax) -- (0,\yMax) node [above,midway] {$z_3(t)$};
      \draw [axis] (0,0) -- (\xMax,0) node [right] {$t$};
      \draw [thick, spot] plot [id=welle-schwingung-3, domain=0:\D]
         function {-\Ai*sin(2*pi/\Ti*x+pi)};
      \node (n) at (0,0) [
         circle,
         font=\sffamily\tiny,
         spot,
         draw, thick,
         fill=white,
         inner sep=0pt,
         minimum size=2mm,
         outer sep=0.5mm,
      ] {3};
      \draw [spot,thick,-{Triangle[scale=0.7]}] (n) -- ++(0,\Ai);
      \coordinate (N3) at (5*\Ti/4,0);
   \end{scope}
   \begin{scope}[shift={($(4)+(S)+(0,\A)$)}, rotate=-90]
      \draw [axis] (0,-\yMax) -- (0,\yMax) node [above,midway] {$z_4(t)$};
      \draw [axis] (0,0) -- (\xMax,0) node [right] {$t$};
      \draw [thick, spot] plot [id=welle-schwingung-4, domain=0:\D]
         function {\Ai*sin(2*pi/\Ti*x+3*pi/2)};
      \node (n) at (0,-\Ai) [
         circle,
         font=\sffamily\tiny,
         spot,
         draw, thick,
         fill=white,
         inner sep=0pt,
         minimum size=2mm,
         outer sep=0.5mm,
      ] {4};
      \draw [spot,thick,-{Triangle[scale=0.7]}] (n) -- ++(0,\Ai);
      \coordinate (N4) at (6*\Ti/4,0);
   \end{scope}
   \begin{scope}[shift={($(5)+(S)$)}, rotate=-90]
      \draw [axis] (0,-\yMax) -- (0,\yMax) node [above,midway] {$z_5(t)$};
      \draw [axis] (0,0) -- (\xMax,0) node [right] {$t$};
      \draw [thick, spot] plot [id=welle-schwingung-5, domain=0:\D]
         function {-\Ai*sin(2*pi/\Ti*x+2*pi)};
      \node (n) at (0,0) [
         circle,
         font=\sffamily\tiny,
         spot,
         draw, thick,
         fill=white,
         inner sep=0pt,
         minimum size=2mm,
         outer sep=0.5mm,
      ] {5};
      \draw [spot,thick,-{Triangle[scale=0.7]}] (n) -- ++(0,-\Ai);
      \coordinate (U5) at (0,0);
      \coordinate (N5) at (7*\Ti/4,0);
   \end{scope}
   % help lines
   \foreach \x in {0.25,0.5,...,2} {
      \begin{scope}[on background layer]
         \draw [dotted] ($(U1)+(-\yMax,-\x*\Ti)$) -- ($(U5)+(\yMax,-\x*\Ti)$);
      \end{scope}
   }
   % pahse shift
   \foreach \n [remember=\n as \lastn (initially 1)] in {2,3,4,5} {
      \draw [gray,thick] (N\lastn) -| ($(N\lastn)!0.5!(N\n)$) |- (N\n);
   }
   \draw [gray,thick] (N1) -- ++(-\yMax,0);
   \draw [gray,thick] (N5) -- ++(\yMax,0);
\end{tikzpicture}

Standing wave

standing wave

\begin{tikzpicture}
   % define variables
   %% wave
   \pgfmathsetmacro\T{9}
   \pgfmathsetmacro\A{1.75}
   %% oscillations
   \pgfmathsetmacro\Ti{0.9}
   \pgfmathsetmacro\Ai{0.3}
   \pgfmathsetmacro\yMax{0.5}
   \pgfmathsetmacro\xMax{2*\Ti+0.3}
   \pgfmathsetmacro\D{2*\Ti+0.1}
   \coordinate (S) at (0,-2.7);
   % wave
   %% axis
   \draw [axis] (0,-2) -- (0,2.6) node [left] {$z(x,t_0)$};
   \draw [axis] (0,0) -- (10,0) node [below] {$x$};
   \draw [tick, |-] (0,\A) node [left] {$z_\text{m}$} -- (0,0);
   %% wave length
   \draw [|-|] (0,2.2) -- ++ (\T,0) node [midway,above] {$\lambda$};
   %% wave form
   \draw [ultra thick, gray] plot [id=stehende-welle, domain=-\yMax-0.1:\T+\yMax]
      function {\A*sin(2*pi/\T*x)};
   \pgfmathsetmacro\X{0.425*\T}
   \pgfmathsetmacro\Y{\A*sin(2*pi/\T*\X r)}
   \draw [gray] (\X,\Y) -- ++(35:0.7) node [right,align=left]
      {\textbf{snapshot} of wave\\ at time $t=t_0$};
   %% osizllationg points (II)
   \coordinate (1) at (0.00*\T,0);
   \coordinate (2) at (0.25*\T,\A);
   \coordinate (3) at (0.50*\T,0);
   \coordinate (4) at (0.75*\T,-\A);
   \coordinate (5) at (1.00*\T,0);
   \pgfmathsetmacro\X{0.125*\T}
   \pgfmathsetmacro\Yvi{\A*sin(2*pi/\T*\X r)}
   \coordinate (6) at (\X,\Yvi);
   \pgfmathsetmacro\X{0.375*\T}
   \pgfmathsetmacro\Yvii{\A*sin(2*pi/\T*\X r)}
   \coordinate (7) at (\X,\Yvii);
   \pgfmathsetmacro\X{0.625*\T}
   \pgfmathsetmacro\Yviii{\A*sin(2*pi/\T*\X r)}
   \coordinate (8) at (\X,\Yviii);
   \pgfmathsetmacro\X{0.875*\T}
   \pgfmathsetmacro\Yix{\A*sin(2*pi/\T*\X r)}
   \coordinate (9) at (\X,\Yix);
   \foreach \n in {1,2,3,4,5,6,7,8,9} {
      \node (n\n) at (\n) [
         circle,
         font=\sffamily\scriptsize,
         spot,
         draw, ultra thick,
         fill=white,
         inner sep=0pt,
         minimum size=3mm,
         outer sep=1mm,
      ] {\n};
   }
   %% movment of points
   \draw [spot,thick,->] (n2) -- ++(0,-0.5*\A);
   \draw [spot,thick,->] (n4) -- ++(0,0.5*\A);
   \draw [spot,thick,->] (n6) -- ++(0,-0.5*\Yvi);
   \draw [spot,thick,->] (n7) -- ++(0,-0.5*\Yvii);
   \draw [spot,thick,->] (n8) -- ++(0,-0.5*\Yviii);
   \draw [spot,thick,->] (n9) -- ++(0,-0.5*\Yix);
   % oscillations
   \begin{scope}[shift={($(1)+(S)$)}, rotate=-90]
      %% axis
      \draw [axis] (0,-\yMax) -- (0,\yMax) node [above,midway] {$z_1(t)$};
      \draw [axis] (0,0) -- (\xMax,0) node [right] {$t$};
      %% sine form
      \draw [thick, spot] plot [id=stehende-welle-schwingung-1, domain=0:\D]
         function {0};
      %% oscillating point (particle)
      \node (n) at (0,0) [
         circle,
         font=\sffamily\tiny,
         spot,
         draw, thick,
         fill=white,
         inner sep=0pt,
         minimum size=2mm,
         outer sep=0.5mm,
      ] {1};
      %% origin coordinate for later use
      \coordinate (U1) at (0,0);
      %% root coordinate for later use
      \coordinate (N1) at (5*\Ti/4,0);
   \end{scope}
   \begin{scope}[shift={($(2)+(S)+(0,-\A)$)}, rotate=-90]
      \draw [axis] (0,-\yMax) -- (0,\yMax) node [above,midway] {$z_2(t)$};
      \draw [axis] (0,0) -- (\xMax,0) node [right] {$t$};
      \draw [thick, spot] plot [id=stehende-welle-schwingung-2, domain=0:\D]
         function {\Ai*sin(2*pi/\Ti*x+pi/2)};
      \node (n) at (0,\Ai) [
         circle,
         font=\sffamily\tiny,
         spot,
         draw, thick,
         fill=white,
         inner sep=0pt,
         minimum size=2mm,
         outer sep=0.5mm,
      ] {2};
   \end{scope}
   \begin{scope}[shift={($(3)+(S)$)}, rotate=-90]
      \draw [axis] (0,-\yMax) -- (0,\yMax) node [above,midway] {$z_3(t)$};
      \draw [axis] (0,0) -- (\xMax,0) node [right] {$t$};
      \draw [thick, spot] plot [id=stehende-welle-schwingung-3, domain=0:\D]
         function {0};
      \node (n) at (0,0) [
         circle,
         font=\sffamily\tiny,
         spot,
         draw, thick,
         fill=white,
         inner sep=0pt,
         minimum size=2mm,
         outer sep=0.5mm,
      ] {3};
   \end{scope}
   \begin{scope}[shift={($(4)+(S)+(0,\A)$)}, rotate=-90]
      \draw [axis] (0,-\yMax) -- (0,\yMax) node [above,midway] {$z_4(t)$};
      \draw [axis] (0,0) -- (\xMax,0) node [right] {$t$};
      \draw [thick, spot] plot [id=stehende-welle-schwingung-4, domain=0:\D]
         function {-\Ai*sin(2*pi/\Ti*x+pi/2)};
      \node (n) at (0,-\Ai) [
         circle,
         font=\sffamily\tiny,
         spot,
         draw, thick,
         fill=white,
         inner sep=0pt,
         minimum size=2mm,
         outer sep=0.5mm,
      ] {4};
   \end{scope}
   \begin{scope}[shift={($(5)+(S)$)}, rotate=-90]
      \draw [axis] (0,-\yMax) -- (0,\yMax) node [above,midway] {$z_5(t)$};
      \draw [axis] (0,0) -- (\xMax,0) node [right] {$t$};
      \draw [thick, spot] plot [id=stehende-welle-schwingung-5, domain=0:\D]
         function {0};
      \node (n) at (0,0) [
         circle,
         font=\sffamily\tiny,
         spot,
         draw, thick,
         fill=white,
         inner sep=0pt,
         minimum size=2mm,
         outer sep=0.5mm,
      ] {5};
      \coordinate (U5) at (0,0);
      \coordinate (N5) at (5*\Ti/4,0);
   \end{scope}
   \begin{scope}[shift={($(6)+(S)-(0,\Yvi)$)}, rotate=-90]
      \draw [axis] (0,-\yMax) -- (0,\yMax) node [above,midway] {$z_6(t)$};
      \draw [axis] (0,0) -- (\xMax,0) node [right] {$t$};
      \draw [thick, spot] plot [id=stehende-welle-schwingung-6, domain=0:\D]
         function {\Yvi/\A*\Ai*sin(2*pi/\Ti*x+pi/2)};
      \node (n) at (0,\Yvi/\A*\Ai) [
         circle,
         font=\sffamily\tiny,
         spot,
         draw, thick,
         fill=white,
         inner sep=0pt,
         minimum size=2mm,
         outer sep=0.5mm,
      ] {6};
      \coordinate (U6) at (0,0);
   \end{scope}
   \begin{scope}[shift={($(7)+(S)-(0,\Yvii)$)}, rotate=-90]
      \draw [axis] (0,-\yMax) -- (0,\yMax) node [above,midway] {$z_7(t)$};
      \draw [axis] (0,0) -- (\xMax,0) node [right] {$t$};
      \draw [thick, spot] plot [id=stehende-welle-schwingung-7, domain=0:\D]
         function {\Yvii/\A*\Ai*sin(2*pi/\Ti*x+pi/2)};
      \node (n) at (0,\Yvii/\A*\Ai) [
         circle,
         font=\sffamily\tiny,
         spot,
         draw, thick,
         fill=white,
         inner sep=0pt,
         minimum size=2mm,
         outer sep=0.5mm,
      ] {7};
      \coordinate (U7) at (0,0);
   \end{scope}
   \begin{scope}[shift={($(8)+(S)-(0,\Yviii)$)}, rotate=-90]
      \draw [axis] (0,-\yMax) -- (0,\yMax) node [above,midway] {$z_8(t)$};
      \draw [axis] (0,0) -- (\xMax,0) node [right] {$t$};
      \draw [thick, spot] plot [id=stehende-welle-schwingung-8, domain=0:\D]
         function {\Yviii/\A*\Ai*sin(2*pi/\Ti*x+pi/2)};
      \node (n) at (0,\Yviii/\A*\Ai) [
         circle,
         font=\sffamily\tiny,
         spot,
         draw, thick,
         fill=white,
         inner sep=0pt,
         minimum size=2mm,
         outer sep=0.5mm,
      ] {8};
      \coordinate (U8) at (0,0);
   \end{scope}
   \begin{scope}[shift={($(9)+(S)-(0,\Yix)$)}, rotate=-90]
      \draw [axis] (0,-\yMax) -- (0,\yMax) node [above,midway] {$z_9(t)$};
      \draw [axis] (0,0) -- (\xMax,0) node [right] {$t$};
      \draw [thick, spot] plot [id=stehende-welle-schwingung-9, domain=0:\D]
         function {\Yix/\A*\Ai*sin(2*pi/\Ti*x+pi/2)};
      \node (n) at (0,\Yix/\A*\Ai) [
         circle,
         font=\sffamily\tiny,
         spot,
         draw, thick,
         fill=white,
         inner sep=0pt,
         minimum size=2mm,
         outer sep=0.5mm,
      ] {9};
      \coordinate (U9) at (0,0);
   \end{scope}
   % help lines
   \foreach \x in {0.25,0.5,...,2} {
      \begin{scope}[on background layer]
         \draw [dotted] ($(U1)+(-\yMax,-\x*\Ti)$) -- ($(U5)+(\yMax,-\x*\Ti)$);
      \end{scope}
   }
   % (no) phase shift
   \draw [gray,thick] ($(N1)-(\yMax,0)$) -- ($(N5)+(\yMax,0)$);
\end{tikzpicture}

Organ pipe

organ pipe

\begin{tikzpicture}
   % define varaibles
   %% pipe foot
   \def\F{2.25}
   \def\r{0.1}
   %% wave length
   \def\w{20}
   %% amplitude
   \def\z{0.5}
   %% wave body
   \def\R{0.6}
   \pgfmathsetmacro\l{0.6*\R}
   \pgfmathsetmacro\L{\w/2-\l}
   %% cut
   \def\A{0.8}
   \def\hA{0.4}
   %% distance for captions
   \pgfmathsetmacro\B{\R+0.3}
   % wave
   \draw [ultra thick, spot,fill=spot!20] plot [id=pfeifen-welle-1,domain=0:\w/2] function
      {\z*sin(2*pi/\w*x)};
   \draw [ultra thick, spot,fill=spot!20] plot [id=pfeifen-welle-2,domain=0:\w/2] function
      {-\z*sin(2*pi/\w*x)};
   % axis
   \draw [axis] (-\F-\hA-\A/2,0) -- (\w/2+0.35,0) node [below left] {$x$};
   % pipe
   \draw [ultra thick] (-\F-\hA-\A/2,-\r) -- (-\hA-\A/2,-\R) -- (\L,-\R)
      (-\F-\hA-\A/2,\r) -- (-\hA-\A/2,\R) -- ++(\hA,0) ++(\A,0) -- (\L,\R);
   ;
   \draw [line width=3pt] (0,-\R) -- (0,\R-\A/8);
   \draw [dashed] (\L,-\R) -- (\L,\R);
   % captions
   \node at (\w/4,0) [spot,fill=spot!20] {$\Delta p(x,0)$};
   \draw [tick, |-|] (-\F-\hA-\A/2,-\B) -- (0,-\B) node [midway,below] {foot length};
   \draw [tick, |-|] (0,-\B) -- (\L,-\B) node [midway,below] {reduced length $L_\text{r}$};
   \draw [tick, |-|] (\L,-\B) -- (\L+\l,-\B) node [midway,below] {$\ell$};
   \draw [tick, |-|] (0,\B) -- (\w/2,\B) node [midway,above] {theoretical length $L$};
\end{tikzpicture}

Helmholtz’ model for the open end

helmholtz model

\begin{tikzpicture}
   % define variables
   \def\H{0.275}
   \def\S{1.8}
   \def\B{8}
   \def\T{4.5}
   \def\l{2.6}
   \def\s{0.3}
   \pgfmathsetmacro\w{atan((\S+\H/2)/\T)}
   \pgfmathsetmacro\R{sqrt(\T^2+(\S+\H/2)^2)}
   %% wave parameters
   \pgfmathsetmacro\wL{6.5*\H}
   \pgfmathsetmacro\wA{\H/2}
   \pgfmathsetmacro\D{10*\wL}
   % plane wave
   \begin{axis}[wave axis]
      \addplot3[wave plot,domain=-\B:0.05,domain y=-\wA:\wA] {abs(sin(pi/\wL * x))};
%      \addplot[domain=-\D:0,samples=200] function {abs(cos(pi/\wL * x))};
   \end{axis}
   % radial wave
   \begin{scope}
%      \clip (0,-\H/2-\S) -- (-\w:\R) arc [start angle=-\w, end angle=\w, radius=\R]
%         -- (0,\H/2+\S) -- cycle;
      \clip (0,-\H/2-\S) rectangle (\T,\H/2+\S);
      \begin{axis}[wave axis]
         \addplot3[polar wave plot,domain y=0:2*\T] function {abs(sin(pi/\wL * y))*exp(-0.2*y)};
%         \addplot[domain=0:2*\T,samples=200] function {abs(cos(pi/\wL * x))*exp(-0.2*x)};
      \end{axis}
   \end{scope}
   % tube
   \draw [ultra thick] (-\B,\H/2) -| (0,\H/2+\S);
   \draw [ultra thick] (-\B,-\H/2) -| (0,-\H/2-\S);
   % axis
   \draw [axis] (-\B,0) -- ($(\T,0)-(0.25,0)$) node [below left] {$x$};
   \draw [tick,|-] (0,0) node [below right=2pt and 2.5pt,inner sep=0pt] {$0$} -- (1,0);
   \draw [axis] (0,0) -- (25:2.5) node [below] {$\vec{r}$};
   % captions
   \draw (-2.5*\wL,0.25*\H) -- ++(65:.6) node [above] {$\psi_\text{i}$};
   \draw (60:\wL/1.9) -- ++(180:1.1) node [left] {$\psi_\text{a}$};
   \node at (0,-\H/2) [below left, align=right] {cross sectional\\area $A$};
\end{tikzpicture}
\end{document}
31

This was one was my first tikz drawn picture (from a presentation about entropic depletion forces, https://www.dropbox.com/s/s2y238u8s1yx0ck/Main.pdf ). It shows a line optical tweezer.

line optical tweezer

The code is pretty ugly, but my:

\documentclass{standalone}

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{arrows, decorations.markings, calc, fadings, decorations.pathreplacing, patterns, decorations.pathmorphing, positioning,snakes,backgrounds,shapes,intersections}
\usepgflibrary{decorations.pathmorphing}
\tikzfading[name=fade out, inner color=transparent!0, outer color=transparent!100]

\begin{document}

\begin{tikzpicture}[xscale=0.28,yscale=0.28]

\node(left_knobble_microscope_down) at (-0.5,0.925) {} ;
\node(left_knobble_microscope_up) at (0,2.075) {} ;
\node(right_knobble) at (2.5,1.5) {} ;

\draw[line width=2] (0,0) -- (14,0) -- (14,6) -- (11,6) -- (11,3) -- (5,3) -- (3,5.5) -- (3,8) -- (0,8) -- (0,-0.115);
\draw[line width=2] (8.25,4.35) -- (8.25,3);
\draw[line width=2] (7,3.65) -- (7,3);
\draw[line width=2] (7.5,4.5) -- (7.5,6.25);
\draw[line width=2] (8,4.7) -- (8,6.25);

\node[circle,fill=black,minimum size=3.5](knobble_right) at (right_knobble) {};
\path[draw] (right_knobble) circle (0.75) node [right=0.05em of right_knobble] {\parbox{10em}{Inverses Mikroskop}};

\node(tableau) at (7,6.5) {}    ;

\node[rectangle, fill=black, minimum width=7em] at (tableau) {};
\draw[fill=black] (left_knobble_microscope_down) rectangle (left_knobble_microscope_up);

\node(ccd_cable_down) at (1,8) {} ;
\node(ccd_cable_up) at (2,10) {} ;
\draw[fill=none,line width=2] (ccd_cable_down) rectangle (ccd_cable_up);

\node(ccd_down) at (0.5,10) {} ;
\node(ccd_up) at (2.5,14) {} ;
\draw[fill=black,line width=2] (ccd_down) rectangle (ccd_up) node [above=0.1ex of ccd_up] {\parbox{3em}{CCD-Kamera}};

\node(right1_down) at (12,6) {} ;
\node(right1_up) at (14,13) {} ;
\draw[fill=none,line width=2] (right1_down) rectangle (right1_up);

\node(right2_down) at (9,13) {} ;
\node(right2_up) at (15,16) {} ;
\draw[fill=none,line width=2] (right2_down) rectangle (right2_up);

\fill[fill=black,line width=2] (9,15.5) -- (8.5,15.5) -- (6.5,14) -- (6.5,13.5) -- (9,13.5);

\draw[line width=2] (7,13.5) -- (7,8.5) -- (8.5,8.5) -- (8.5,13.5);

\fill[fill=black,line width=2] (7,8.5) -- (7.25,8) -- (8.25,8) -- (8.5,8.5);

\node[line width=1,ellipse,draw,gray,name path=focus](focus) at (7.75,6.5) {\phantom{...}};
\node[line width=1,ellipse,draw,gray,name path=focus_big](focus_big) at (24,13) {\phantom{\parbox{3cm}{bla\\bla\\bla\\bla\\}}};
\draw[line width=1,gray,draw=none,name path=focus_bla] (focus.east) -- (focus_big.east);
\draw[line width=1,gray,draw=none,name path=focus_blo] (focus.west) -- (focus_big.west);
\path[name intersections={of=focus_bla and focus_big},draw,line width=1, gray](intersection-1)--(focus.east);
\path[name intersections={of=focus_blo and focus},draw,line width=1, gray](intersection-1)--(focus_big.west);


\draw[shift={(8.5,4.5)},rotate=-60,line width=2,black](0, 0) arc (87.5:272.5:0.5 and 0.9);
\draw[rotate around={30:(8.5,4.5)},fill=black,draw,line width=2](8.75,4.5) rectangle (6.45,4.5) {};
\node[rectangle,draw,line width=2] at (20,3.625) {Teleskop};
\draw[fill=black, name path=objektiv] (14,3.075) rectangle (14.5,4.225);
\draw[rotate around={45:(28,1)},fill=black,draw,line width=2] (27,1) rectangle (29,1) node [below left=2.5ex and 0.15em] {\parbox{3em}{Galvanome\-terspiegel}};
\draw[rotate around={-45:(28.375,4)},fill=black,draw,line width=2] (27.375,3.5) rectangle (29.375,3.5);
\fill[red,fill opacity=0.5] (24.2,0.9) -- (27.735,0.9) -- (27.935,1.1) -- (24.2,1.1);
\fill[red,fill opacity=0.5] (27.935,1.1) -- (28.25,3.25) -- (27.5,4) -- (27.735,0.9);
\fill[red,fill opacity=0.5] (27.5,4) -- (22.85,4.25) -- (22.85,3) -- (28.25,3.25);

\fill[red,fill opacity=0.5] (17.15,4.25) -- (14.525,4.125) -- (14.525,3.2) -- (17.15,3);
\fill[red,fill opacity=0.5] (10.885,3.965) -- (8.37,3.85) -- (8.37,3.65) -- (10.885,3.4675);
 \node[rectangle,draw,line width=2] at (20,1) {Nd:YLF-Laser};
\node at (24,9.5) {Deckglas};
\draw[<->,line width=2] (20,11) to (28,11);

    \draw[line width=1] (20,12.25) node[ellipse, minimum height=0.1,minimum width=42.5,draw](down_left) {};
    \draw[line width=1] (20,15.75) node[ellipse, minimum height=0.1,minimum width=42.5,draw](top_left) {};
    \draw[line width=1] (28,12.25) node[ellipse, minimum height=0.1,minimum width=42.5,draw](down_right) {};
    \draw[line width=1] (28,15.75) node[ellipse, minimum height=0.1,minimum width=42.5,draw](top_right) {};
    \draw[line width=1] ($(down_left.10)+(0,-0.05)$)..controls (20,13.75) and (20,14.25)..($(top_left.-10)+(0,0.05)$);
    \draw[line width=1] ($(down_right.10)+(0,-0.05)$)..controls (28,13.75) and (28,14.25)..($(top_right.-10)+(0,0.05)$);
    \draw[line width=1] ($(down_right.170)+(0,-0.05)$)..controls (28,13.75) and (28,14.25)..($(top_right.-170)+(0,0.05)$);
    \draw[line width=1] ($(down_left.170)+(0,-0.05)$)..controls (20,13.75) and (20,14.25)..($(top_left.-170)+(0,0.05)$);

    \node[shade,shading=ball,circle,ball color=blue,minimum size=1.25em] at (23,14)  {};
    \node[shade,shading=ball,circle,ball color=blue,minimum size=1.25em] at (25,14)  {};

\begin{pgfonlayer}{background}
\begin{scope}
\clip ([yshift=1.75pt]down_left.south) -- ([yshift=1.75pt]down_right.south) -- (down_right.-85) -- (down_right.-80) -- (down_right.-75) -- (down_right.-70) -- (down_right.-65) -- (down_right.-60) -- (down_right.-55) -- (down_right.-50) -- (down_right.-45) -- (down_right.-40) -- (down_right.-35) -- (down_right.-30) -- (down_right.-25) -- (down_right.-20) -- (down_right.-15) -- (down_right.-10) -- (down_right.-5) -- (down_right.east) -- (down_right.5) -- (down_right.10) -- ($(down_right.10)+(0,-0.05)$)..controls (28,13.75) and (28,14.25)..($(top_right.-10)+(0,0.05)$) -- (top_right.-10) -- (top_right.-5) -- (top_right.east) -- (top_right.5) -- (top_right.10) -- (top_right.15) -- (top_right.20) -- (top_right.25) -- (top_right.30) -- (top_right.35) -- (top_right.40) -- (top_right.45) -- (top_right.50) -- (top_right.55) -- (top_right.60) -- (top_right.65) -- (top_right.70) -- (top_right.75) -- (top_right.80) -- (top_right.85) -- (top_right.90) -- ([yshift=-1.75pt]top_right.north) -- ([yshift=-1.75pt]top_left.north) -- (top_left.-210) -- (top_left.-205) -- (top_left.-200) -- (top_left.-195) -- (top_left.-190) -- (top_left.-185) -- (top_left.-180) -- (top_left.-175) -- (top_left.west) -- ($(top_left.-170)+(0,0.05)$)..controls (20,14.25) and (20,13.75)..($(down_left.170)+(0,-0.05)$) -- (down_left.-210) -- (down_left.-205) -- (down_left.-200) -- (down_left.-195) -- (down_left.-190) -- (down_left.-185) -- (down_left.-180) -- (down_left.-175) -- (down_left.-170) -- (down_left.-165) -- (down_left.-160) -- (down_left.-155) -- ([yshift=1.75pt]down_left.south);
\draw[draw=none] [postaction={path fading=north,fill=red,opacity=0.8}] (16,14) rectangle (32,17);
\draw[draw=none] [postaction={path fading=south,fill=red,opacity=0.8}] (16,14) rectangle (32,11);
\end{scope}

\fill[blue!50!white,fill opacity=0.5] (focus_big.-20) -- (focus_big.-40) -- (focus_big.-140) -- (focus_big.-160);
\draw[line width=1,gray!75!black] ([yshift=1.75pt]down_left.south) to ([yshift=1.75pt]down_right.south);
\draw[line width=1,gray!75!black] ([yshift=1.75pt]top_left.south) to ([yshift=1.75pt]top_right.south);
\draw[line width=1,gray!75!black] ([yshift=-1.75pt]down_left.north) to ([yshift=-1.75pt]down_right.north);
\draw[line width=1,gray!75!black] ([yshift=-1.75pt]top_left.north) to ([yshift=-1.75pt]top_right.north);
\end{pgfonlayer}

\end{tikzpicture}

\end{document}
  • 2
    The beamer presentation that you linked is awesome – Thomas Feb 6 '14 at 16:02
  • Should be Galvano-meterspiegel – m33lky Feb 10 '14 at 19:14
  • 1
    link is dead :( – Peter Ebelsberger Apr 3 '15 at 9:57
30

Newton's rings.

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes}
\usepackage{amsmath}
\begin{document}
  \pagecolor{yellow!50}
  \begin{tikzpicture}[note/.style={rectangle callout, fill=#1}]
  \foreach \x in {1,2,...,22}{  
     \draw[thick] (0,0) circle ({sqrt(\x)});
  }
  \fill[black!100] (0,0) circle (1);
  \foreach \x in {23,24,...,28}{
    \draw[black!30] (0,0) circle ({sqrt(\x)});
  }
  \node (v1) at (-1.014,-6.5) {\Large $m^\text{th}$ ring};
  \draw[very thick,latex-](v1) -- (-1.014,-0.98);
  \node (v2) at (1.414,-5.8) {\Large $\left(m+1\right)^\text{th}$ ring};
  \draw[very thick,latex-](v2) -- (1.414,-1);
  \draw[very thick,-](1.414,6) -- (1.414,0);
  \draw[very thick,-](-1.414,6) -- (-1.414,0);
  \draw[very thick,latex-latex](-1.414,5.8) -- (1.414,5.8);
  \node at (0,6.1) {\Large $D_{m}$};
  \draw[very thick,latex-latex](4.6904,7.4) -- (-4.6904,7.4);
  \node at (0,7.7) {\Large $D_{m+21}$};
  \node [draw,note=white!100, callout relative pointer={(2.05,-2.8)}] at (-7,3) {\Large Take first
     reading};
  \node (v3) at (-4.6904,8) {\Large $m+21$};
  \draw[very thick,-](v3) -- (-4.6904,0);
  \node [draw,note=white!100, callout relative pointer={(-2.05,-2.8)}] at (7,3) {\Large Take last
      reading};
  \node (v4) at (4.6904,8) {\Large $m+21$};
  \draw[very thick,-](v4) -- (4.6904,0);
\end{tikzpicture} 
\end{document}

enter image description here

Explanation:

We have an experiment in optics to measure the focal length of a lens using Newton's ring set up. This diagram is an illustration provided in the manual depicting the rings pattern. The radii of the rings are accurately equal to square root of 1,2,3..... Students take readings for only 21 rings and hence they are made dark for visibility.

30

I couldn't bear to let this go without at least one example of a picture produced by mfpic. It is not very flashy, but it illustrates that mfpic has built-in commands to produce figures in the hyperbolic geometry of a disk (for those of us who study function theory in the unit disk.):

\documentclass{article}
\usepackage[metapost,mplabels]{mfpic}
\opengraphsfile{mypics}
\begin{document}
Hyperbolic metric disks:

\begin{mfpic}[72]{-1}{1}{-1}{1}
  \setmfpair{Z}{(dir 45)/3}
  \setmfpair{W}{Moebius (Z)(.5*dir -45)}
  \draw\gfill[gray(.94)]\circle{(0,0),1}
  \draw\gfill[gray(.87)]\pshcircle{Z,4/5}
  \gfill[gray(.80)]\pshcircle{Z,1/2}
  \draw\gfill[gray(.73)]\pshcircle{W,1/2}
  \draw\pshcircle{Z,1/2}
  \tlpointsep{3bp}
  \point{Z,W,(0,0)}
  \tlabel[br]{Z}{$z$}
  \tlabel[tl]{W}{$w$}
  \tlabel[tr]{(0,0)}{$0$}
\end{mfpic}

Hyperbolic geodesics:

\begin{mfpic}[72]{-1}{1}{-1}{1}
  \circle{(0,0),1}
  \draw\gfill[gray(.88)]
    \lclosed
    \connect
      \hypergeodesic{.999*dir 0, .999*dir 120}
      \hypergeodesic{.999*dir 120, .999*dir 240}
      \hypergeodesic{.999*dir 240, .999*dir 0}
    \endconnect
  \mfpfor{K=6,12,24,48}
    \mfpfor{J=0 upto K-1}
      \rotatepath{(0,0),J*(360/K)}\hypergeodesic{.999*dir 0, .999*dir (360/K)}
    \endmfpfor
  \endmfpfor
\end{mfpic}

\closegraphsfile
\end{document}

Some hyperbolic disks

Hyperbolic geodesics

  • I think you'll get a lot more upvotes (including mine) if you can show a hyperbolic tiling--say, a fundamental domain for a genus two surface. The image you have here does not look particularly hyperbolic. – Charles Staats Feb 7 '14 at 21:51
  • The circles are produce by providing the command \pshcircle with a point and the pseudohyperbolic radius. This is what makes it hyperbolic. A hyperbolic tiling would be much more complex and I wanted to keep it simple (because Riemann surfaces are not really part of my mathematical skills set). But I'll see what I can come up with. – Dan Feb 7 '14 at 22:45
  • @CharlesStaats I don't know whether that's a "genus two surface", but it is a tiling by hyperbolic domains. – Dan Feb 9 '14 at 1:09
  • Good enough for me. +1. – Charles Staats Feb 9 '14 at 1:11
  • @Dan May I ask, do you know a way to use mfpic to draw hyperbolic line segments between two points? Or to clip, so that it looks like they're segments? This would be truely wonderful. – gebruiker Aug 4 '17 at 19:54
30

The butterfly curve.

\documentclass{article}
\usepackage{xpicture}
\begin{document}

\DIVIDE{1}{12}{\invXII}
\MULTIPLY{12}{\numberTWOPI}{\phione}  
\MULTIPLY{12}{64}{\divisions}  

\COMPOSITIONfunction{\EXPfunction}{\COSfunction}{\Afunction}
\SCALEVARIABLEfunction{4}{\COSfunction}{\Bfunction}
\SCALEVARIABLEfunction{\invXII}{\SINfunction}{\cfunction}
\POWERfunction{\cfunction}{5}{\Cfunction}
\LINEARCOMBINATIONfunction{1}{\Afunction}{-2}{\Bfunction}{\ABfunction}
\SUBTRACTfunction{\ABfunction}{\Cfunction}{\ABCfunction}
\PRODUCTfunction{\SINfunction}{\ABCfunction}{\Xfunction}
                % x=(sin t)(exp(cos t)-2 cos 4t + (sin(t/12))^5)
\PRODUCTfunction{\COSfunction}{\ABCfunction}{\Yfunction}     
                % y=(cos t)(exp(cos t)-2 cos 4t + (sin(t/12))^5)
\PARAMETRICfunction{\Xfunction}{\Yfunction}{\butterfly}

\setlength{\unitlength}{1cm}

\centering
\begin{Picture}(-4,-3)(4,4)
    \PlotParametricFunction[\divisions]\butterfly{0}{\phione}   
\end{Picture}
\[
  \mathbf{f}(t)=
     \left(\mathrm{e}^{\cos t}-2\cos 4t+\sin^5 \frac{t}{12}\right)
     (\sin t,\cos t)
\]

\end{document}

The butterfly curve

29

Language used - Asymptote

A quarter sessile drop

import three;
import solids;

unitsize(1cm);

currentprojection = orthographic(5,4,2);

path3 x = (-1,0,0)--(4.5,0,0);
draw(x,EndArrow3);
label("$x$",(4.7,0,0));

path3 y = (0,-1,0)--(0,4.5,0);
draw(y,EndArrow3);
label("$y$",(0,4.7,0));

path3 z = (0,0,-1)--(0,0,4.5);
draw(z,EndArrow3);
label("$z$",(0,0,4.7));

label("$O$",(0,-0.3,-0.5));

path3 a = arc(O,3,0,0,90,0);
draw(a);
revolution s = revolution(O,a,Z,0,90);
draw(surface(s),opacity(0.5)+cyan,light(0));

path3[] b = box(O,(2.2,2.2,3));
draw(b,dashed);


path3 c = O--(3*dir(30,0));
draw(c,EndArrow3);
path3 d = (3*dir(30,0))--(4.5*dir(30,0));
draw(d);
path3 e = (4.5*dir(30,0))--(4.5*dir(30,0)+(1,0,0));
draw("$R$",e);

path3 f = (3,0,0)--(3,0,1);
draw(f);
path3 g = (2.8,0,0)..(2.8,0,0.2)..(3,0,0.2);
draw("$\theta$",g);

enter image description here

Moving contact line

    unitsize(1cm);

path a = (1,2.4)--(4,0.6)..(4.5,1)..(4.1,1.9)..(3.9,2)..cycle;
draw(a);
fill(a,cyan);

path b = (0,3)--(5,0);
draw(b,linewidth(2));

path c = shift(4,0.6)*scale(0.6)*unitcircle;
draw(c,red+dashed);


path d = (5,1.2)--(6,1.8);
draw(d,EndArrow);


path e = shift(8,3)*scale(2)*unitcircle;
draw(e,red+dashed);


path f = (9.4,1.6)--(6.1,3.58);
draw(f,linewidth(2));

path g = (8,2.44)..(8.8,3.2)..(8.6,3.8)..(8.4,4.1);
draw(g,dashed);
dot(g,red);
label("$a_0,a_1$",(8,2.44),SW);
label("$b_0$",(8.8,3.2),W);
label("$c_0$",(8.6,3.8),W);
label("$d_0$",(8.4,4.1),NW);

path h = (8,2.44)--(8.8,1.96)..(9.1,2.9)..(9.0,3.5);
draw(h);
dot(h,red);
label("$b_1$",(8.8,1.96),SW);
label("$c_1$",(9.1,2.9),NE);
label("$d_1$",(9.0,3.5),NE);

enter image description here

  • What language is that? – jubobs Feb 6 '14 at 12:47
  • Asymptote @Jubobos – Aashutosh Feb 6 '14 at 12:48
  • Edit your answer to specify that the language used is Asymptote, and you've got my upvote :) – jubobs Feb 6 '14 at 12:50
26

Configuration Space and Symbolic Subspace of a 2-Degrees of Freedom Robot

Depending on its configuration, it can either be in the symbolic state of penetrating the wall, or not penetrating it.

Configuration Space and Symbolic Subspace of a Simple Robot

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes}
\usepackage{amsmath}
\begin{document}

\newdimen\xbase
\newdimen\ybase 
\def\endDom{4}
\begin{tikzpicture}[domain=0:4]
  \def\ColSymBorder{black}
  \def\ColSymBorderTwo{black}
  \def\ColSymFill{gray!70}
  \def\ColSymFillTwo{gray!20}
  \def\wallColor{gray!70}
  \tikzstyle{block} = [draw, color=\ColSymBorder, ultra thick, fill=\ColSymFill, rectangle,  minimum height=3em, minimum width=6em];
  \draw[color=\ColSymBorderTwo, ultra thick, fill=\ColSymFillTwo] (0,0) rectangle (4,4);
  \draw (0,0) node[below,left]{$0^\circ$} -- (4,0) node[below,midway] {$\theta_1$} node[below,right] {$180^\circ$};
  \draw (0,0) -- (0,4) node[left,midway] {$\theta_2$} node[left] {$180^\circ$};

  \def\wallOffset{50pt}
  \def\marginOff{5pt}


  \draw[ultra thick,color=\ColSymBorder,fill=\ColSymFill, rounded corners=3pt] 
                   (0,0.2) .. controls (0,1) and (0,2) ..   (0,3.8)
                         .. controls (0.3,3.5) and (0.8,3.1) .. (1,2.6)
                         .. controls (1.4,2.0) and (1.6,1.2) .. (2,0)
                         .. controls (1,0) and (0.5,0) .. (0.3,0)
                         .. controls (0.2,0.1) and (0.1,0.2) .. (0,0.3);
                         %.. controls (3,0) and (2,0) .. (0,0);

  \newcounter{i}
  \setcounter{i}{0}
  \foreach \x in {1,100,...,180}{
   \foreach \y in {1,100,...,180}{
     %\ifthenelse{ {cos(\x)*40+50/cos(90-(\x+\y))} < 50}
     %\ifthenelse{ \lengthtest{ {\f{\x}} pt < 50 pt}}

       \pgfmathparse{ (
       (cos(\x)*40pt+sin(\x+\y)*50pt)<(\wallOffset+\marginOff)) &&
       (cos(\x)*40pt+sin(\x+\y)*50pt)>(\wallOffset-\marginOff))) ?1:0}
       \ifnum\pgfmathresult>0
          %penetrates the wall
          \stepcounter{i}
       \else
          %out of the wall
       \fi


   }
  }

  \draw[thick,color=\ColSymBorder] (-2,1) -- (0,1);
  \node[block] at (-3,1) {$s_0: $ penetratesWall};
  \draw[thick,color=\ColSymBorderTwo] (6,3) -- (4,3);
  \node[draw, color=\ColSymBorderTwo, ultra thick, fill=\ColSymFillTwo, rectangle,
  minimum height=3em, minimum width=6em] at (7,3) {$s_1: \neg$penetratesWall};

  %%%%%%%% PAINTING THE ROBOT STARTS HERE:

  \newcommand*{\Robot}[4]{
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \pgfmathsetlengthmacro{\rone}{40pt} %length link1
    \pgfmathsetlengthmacro{\rtwo}{50pt} %length link2
    \pgfmathsetlengthmacro{\rw}{10} %width of base rectangle
    \pgfmathsetlengthmacro{\thetaone}{#1} %angle base-link1
    \pgfmathsetlengthmacro{\thetatwo}{#2} %angle link1-link2
    \coordinate (base) at (#3,#4); %base coordinates

    %\coordinage (cspace) at ({#1/180*\endDom},{#2/180*\endDom})

    \path (base);
    \pgfgetlastxy{\xbase}{\ybase};
    \draw[thick,color=black] ({\xbase+1cm},{\ybase+3.0cm}) -- ({#1/180*\endDom},{#2/180*\endDom});
    \draw[fill=black] ({#1/180*\endDom},{#2/180*\endDom}) circle (2pt);


    \draw[thick,color=black] ({\xbase-1cm},{\ybase-0.5cm}) rectangle
    ({\xbase+3cm},{\ybase+3cm});

    \draw[fill=\wallColor] ({\xbase+\wallOffset}, {\ybase-0.5cm}) rectangle
    ({\xbase+3cm}, {\ybase+3cm});

    \pgfmathsetlengthmacro{\tx}{\rone*cos(\thetaone)+\xbase}
    \pgfmathsetlengthmacro{\ty}{\rone*sin(\thetaone)+\ybase}
    \coordinate (t1) at (\tx,\ty);

    \pgfmathsetlengthmacro{\sx}{\rtwo*sin(\thetaone+\thetatwo)+\tx}
    \pgfmathsetlengthmacro{\sy}{-\rtwo*cos(\thetaone+\thetatwo)+\ty}
    \coordinate (t2) at (\sx,\sy);
    \draw[ultra thick,black] (base) -- (t1);% node[below] {$\tx \ybase \xbase \ty$};
    \draw[ultra thick,black] (t1) -- (t2);% node[below] {$\tx \ybase \xbase \ty$};

    \draw[thick,color=black,fill=white!30] ({\xbase-0.5*\rw},{\ybase-0.5*\rw}) rectangle++ (\rw,\rw);
    \draw[thick,color=black,fill=white!10] (t1) circle (2pt);
    \draw[thick,color=black,fill=white!10] (t2) circle (2pt);


    %% dashed line to represent link two at 0 degree
    \pgfmathsetlengthmacro{\rtmp}{\rone }
    \pgfmathsetlengthmacro{\tmpx}{\rtmp*sin(\thetaone)+\tx}
    \pgfmathsetlengthmacro{\tmpy}{-\rtmp*cos(\thetaone)+\ty}
    \coordinate (tmp1) at (\tmpx,\tmpy);
    \draw[dashed,color=black] (t1) -- (tmp1);

    %% dashed line to represent link one at 0 degree
    \pgfmathsetlengthmacro{\tmpx}{\rone+\xbase}
    \pgfmathsetlengthmacro{\tmpy}{\ybase}
    \coordinate (tmp0) at (\tmpx,\tmpy);
    \draw[dashed,color=black] (base) -- (tmp0);


    \pgfmathsetlengthmacro{\tmpx}{\rone+\xbase}
    \pgfmathsetlengthmacro{\tmpy}{\ybase}

    \pgfmathsetlengthmacro{\tmpx}{0.9*\rone*cos(\thetaone)+\xbase}
    \pgfmathsetlengthmacro{\tmpy}{0.9*\rone*sin(\thetaone)+\ybase}
    \coordinate (tmp0t) at (\tmpx,\tmpy);

    \pgfmathsetlengthmacro{\tmpx}{0.9*\rtwo*sin(\thetaone+\thetatwo)+\tx}
    \pgfmathsetlengthmacro{\tmpy}{-0.9*\rtwo*cos(\thetaone+\thetatwo)+\ty}
    \coordinate (tmp1t) at (\tmpx,\tmpy);

    % ($(O)+(\StartAngle:-\Radius)$) is the center of the yellow circle

    \draw[bend right,thick,->]  (tmp1) to node [auto] {$\theta_2$} (tmp1t);
    \draw[bend right,thick,->]  (tmp0) to node [auto] {$\theta_1$} (tmp0t);
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  }



  \Robot{40}{40}{-4}{-4.5}
  \Robot{70}{60}{1}{-4.5}
  \Robot{110}{25}{6}{-4.5}
\end{tikzpicture}


\end{document}
25

Here's a Penrose diagram for the (maximal analytic extension of) the Schwarzschild black hole, made with TikZ. enter image description here

\documentclass[border=2mm]{standalone}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathrsfs}

\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,patterns}

\newcommand{\scri}{\mathscr{I}}

\begin{document}

% Penrose diagram for the maximal analytic extension of the Schwarzschild.
  \begin{tikzpicture}
      \draw [thick] (3,0) -- (0,3);
      \draw [thick] (0,3) -- (3,6);
      \draw [thick] (3,6) -- (6,3);
      \draw [thick] (3,0) -- (6,3);

      \draw [thick] (6,3) -- (9,6);
      \draw [thick] (6,3) -- (9,0);
      \draw [thick] (9,6) -- (12,3);
      \draw [thick] (9,0) -- (12,3);

      % Singularity at r=0  
      \draw [decorate, decoration=zigzag, thick] (3,6) -- (9,6);
      \draw [decorate, decoration=zigzag, thick] (3,0) -- (9,0);


      % Hole filled with diagonal lines.
      \fill [decoration={zigzag}]
        [pattern=north east lines,thick] (6,3) -- (9,6)
          decorate { (9,6) -- (3,6) } -- (6,3);
      \fill [decoration={zigzag}]
        [pattern=north west lines,thick] (6,3) -- (9,0)
          decorate { (9,0) -- (3,0) } -- (6,3);

% How embarassing! I've done these by hand, instead of defining a function that draws them. Hopefully this will never get posted on the TeX Stackexchange where people might see it.

      % Lines of constant t in region 1
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({9-0.5*sinh(2.49178*\t)},{6.04138-0.5*cosh(2.49178*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({9-sinh(1.81845*\t)},{6.16228-cosh(1.81845*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({9-2*sinh(1.19476*\t)},{6.60555-2*cosh(1.19476*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({9-4*sinh(0.693147*\t)},{8-4*cosh(0.693147*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({9-8*sinh(0.366725*\t)},{11.554-8*cosh(0.366725*\t)});
      \draw[dashed] (6,3) -- (12,3);
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({9-8*sinh(0.366725*\t)},{-5.554+8*cosh(0.366725*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({9-4*sinh(0.693147*\t)},{-2+4*cosh(0.693147*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({9-2*sinh(1.19476*\t)},{-.60555+2*cosh(1.19476*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({9-sinh(1.81845*\t)},{-0.162278+cosh(1.81845*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({9-0.5*sinh(2.49178*\t)},{-0.0413813+0.5*cosh(2.49178*\t)});


      %Lines of constant t in region 1'
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({3-0.5*sinh(2.49178*\t)},{6.04138-0.5*cosh(2.49178*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({3-sinh(1.81845*\t)},{6.16228-cosh(1.81845*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({3-2*sinh(1.19476*\t)},{6.60555-2*cosh(1.19476*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({3-4*sinh(0.693147*\t)},{8-4*cosh(0.693147*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({3-8*sinh(0.366725*\t)},{11.554-8*cosh(0.366725*\t)});
      \draw[dashed] (0,3) -- (6,3);
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({3-8*sinh(0.366725*\t)},{-5.554+8*cosh(0.366725*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({3-4*sinh(0.693147*\t)},{-2+4*cosh(0.693147*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({3-2*sinh(1.19476*\t)},{-.60555+2*cosh(1.19476*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({3-sinh(1.81845*\t)},{-0.162278+cosh(1.81845*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({3-0.5*sinh(2.49178*\t)},{-0.0413813+0.5*cosh(2.49178*\t)});

      % Lines of constant r in region 1
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({5.95862+0.5*cosh(2.49178 *\t)},{3+0.5*sinh(2.49178 *\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({5.83772+1.0*cosh(1.81845 *\t)},{3+1.0*sinh(1.81845 *\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({5.39445+2.0*cosh(1.19476 *\t)},{3+2.0*sinh(1.19476 *\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({4+4.0*cosh(0.693147*\t)},{3+4.0*sinh(0.693147*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({0.455996+8.0*cosh(0.366725*\t)},{3+8.0*sinh(0.366725*\t)});
      \draw[dashed] (9,0) -- (9,6);
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({17.544-8.0*cosh(0.366725*\t)},{3+8.0*sinh(0.366725*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({14-4.0*cosh(0.693147*\t)},{3+4.0*sinh(0.693147*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({18-5.39445-2.0*cosh(1.19476 *\t)},{3+2.0*sinh(1.19476 *\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({18-5.83772-1.0*cosh(1.81845 *\t)},{3+1.0*sinh(1.81845 *\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({18-5.95862-0.5*cosh(2.49178 *\t)},{3+0.5*sinh(2.49178 *\t)});

      % Lines of constant r in region 1'
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({-6+5.95862+0.5*cosh(2.49178 *\t)},{3+0.5*sinh(2.49178 *\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({-6+5.83772+1.0*cosh(1.81845 *\t)},{3+1.0*sinh(1.81845 *\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({-6+5.39445+2.0*cosh(1.19476 *\t)},{3+2.0*sinh(1.19476 *\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({-6+4+4.0*cosh(0.693147*\t)},{3+4.0*sinh(0.693147*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({-6+0.455996+8.0*cosh(0.366725*\t)},{3+8.0*sinh(0.366725*\t)});
      \draw[dashed] (3,0) -- (3,6);
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({-6+17.544-8.0*cosh(0.366725*\t)},{3+8.0*sinh(0.366725*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({-6+14-4.0*cosh(0.693147*\t)},{3+4.0*sinh(0.693147*\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({-6+18-5.39445-2.0*cosh(1.19476 *\t)},{3+2.0*sinh(1.19476 *\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({-6+18-5.83772-1.0*cosh(1.81845 *\t)},{3+1.0*sinh(1.81845 *\t)});
      \draw[dashed, domain=-1:1,smooth,variable=\t] plot ({-6+18-5.95862-0.5*cosh(2.49178 *\t)},{3+0.5*sinh(2.49178 *\t)});

      % Cauchy Surface $\Sigma$
      \node [inner sep=0pt] (A) at (0,3) {};
      \node [inner sep=0pt] (B) at (6,3) {};
      \node [inner sep=0pt] (C) at (12,3) {};
      \draw [very thick, gray!75!black] (A) to [bend right=8] (B);
      \draw [very thick, gray!75!black] (B) to [bend left=8] (C);

      % Label null infinity     
      \node (scriplus) at (11,5) {\Large $\scri^{+}$};
      \node (scriminus) at (11,1) {\Large $\scri^{-}$};


      \node (iplus) at (9.25,6.3) {\Large $i^{+}$};
      \node (iminus) at (9.25,-0.3) {\Large $i^{-}$};
      \node (inaught) at (12.3,3) {\Large $i^{0}$};

      % Label the singularity
      \node (r0top) at (6,6.5) {\large $r=0$};
      \node (r0bottom) at (6,-0.5) {\large $r=0$};

      % Label the horizon
      \node [fill=white,inner sep=1pt](Hplus) at (7.75,4.1) {\large $\mathcal{H}^{+}$};   
      \node [fill=white,inner sep=1pt](Hminus) at (7.75,1.9) {\large $\mathcal{H}^{-}$};      

      % Label the Cauchy Surface
      \node [fill=white, inner sep=1pt] (Sigma) at (9.5,3.5) {\large $\Sigma$};

  \end{tikzpicture}   

\end{document} 
  • 2
    Couldn't you make use of \foreach in many places? – Manuel Aug 5 '15 at 20:21
  • Yes, it could be improved! – Robert McNees Aug 5 '15 at 20:27
24

Not very scientific and clearly not that awesome as the rest from here, but it was a big deal for me since a knew nothing about TikZ (I still know nothing, though :P). It's the ATDD cycle.

enter image description here

The code it's not pretty.

\documentclass{standalone}

\usepackage[spanish,es-noquoting]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{tikz}
\usetikzlibrary{shadows}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{positioning}
\usetikzlibrary{calc,intersections}

\begin{document}

\begin{tikzpicture}
\tikzset{normalstyle/.style={draw, drop shadow, fill=white, rectangle, inner sep=5pt, font=\bfseries, align=center}}
\tikzset{bubble/.style={draw, circle, fill=white, minimum width=5em}}
\def \radius {0.30\textwidth}

\def \offset{-5} % para que la linea que une rojo con verde sea diagonal

    \draw[dotted, thick] ({90 + \offset - 1}:\radius*1.4) -- ({-90 + \offset -1 }:\radius*1.4);

    \path[name path=circulo] (0, 0) circle (\radius);



    % ELEGIR US
    \node(elegir_us)[normalstyle, name path=path_elegir_us] at ({-173 + \offset}:\radius) {Elegir\\ User Story};

    % START
    \node (start) [node distance=0mm and 8mm, left=of elegir_us, circle, fill=black, minimum width=1pt]{};

    % ESCRIBIR PRUEBAS
    \node(escribir_pruebas)[normalstyle,name path=path_escribir_pruebas] at ({164 + \offset}:\radius) {Escribir pruebas\\ de aceptacion\\ para la Story};

    % IMPLEMENTAR PRUEBA
    \node(implementar_prueba)[normalstyle, name path=path_implementar_prueba] at ({132 + \offset}:\radius) {Implementar\\ prueba de\\    aceptacion};

    % PRUEBA FALLANDO
    \node(prueba_fallando)[name path=path_prueba_fallando,draw, drop shadow, fill=red, rectangle, inner sep=5pt, font=\bfseries, align=center] at ({90 + \offset}:\radius) {Prueba de\\ aceptacion\\ fallando};

    % PRIMER TRIBUBBLE
    \node(prueba1)[bubble,name path=path_prueba1] at ({52 + \offset}:\radius){Prueba};
    \node(codigo1) [bubble, above right = 1mm and 5mm of prueba1.center] {Código};
    \node(refactor1) [bubble,name path=path_refactor1, below right = 1mm and 5mm of prueba1.center] {Refactor};

    % SEGUNDO TRIBUBBLE
    \node(prueba2)[bubble,name path=path_prueba2] at ({0 + \offset}:\radius){Prueba};
    \node(codigo2) [bubble, above right = 1mm and 5mm of prueba2.center] {Código};
    \node(refactor2) [bubble, below right = 1mm and 5mm of prueba2.center] {Refactor};    

    % TERCER TRIBUBBLE
    \node(prueba3)[bubble,name path=path_prueba3] at ({-52 + \offset}:\radius){Prueba};
    \node(codigo3) [bubble,,name path=path_codigo3, above right = 1mm and 5mm of prueba3.center] {Código};
    \node(refactor3) [bubble, below right = 1mm and 5mm of prueba3.center] {Refactor};    

    % PRUEBA PASANDO    
    \node(prueba_pasando)[name path=path_prueba_pasando, draw, drop shadow, fill=green, rectangle, inner sep=5pt, font=\bfseries, align=center] at ({-90 + \offset}:\radius) {Prueba de\\ aceptacion\\ pasando};

    % REFACTOR
    \node(refactor)[normalstyle, name path=path_refactorizar] at ({-128 + \offset}:\radius) {Refactorizar};

    % ACEPTACION CLIENTE
    \node(aceptacion_cliente)[normalstyle, name path=path_aceptacion_cliente] at ({-149 + \offset}:\radius) {Aceptacion\\ Cliente};


    % INTERSECCIONES

    % INTERSECCIÓN ELEGIR USER STORY
    \path [name intersections={of=circulo and path_elegir_us,name=intELEGIRUS}];
\def \ELEGIRUSUP{intELEGIRUS-1}
\def \ELEGIRUSDOWN {intELEGIRUS-2}

    % INTERSECCIÓN ESCRIBIR PRUEBAS
    \path [name intersections={of=circulo and path_escribir_pruebas,name=intESCRIBIRPRUEBAS}];
\def \ESCRIBIRPRUEBASUP {intESCRIBIRPRUEBAS-1}
\def \ESCRIBIRPRUEBASDOWN {intESCRIBIRPRUEBAS-2}

    % INTERSECCIÓN IMPLEMENTAR PRUEBA
    \path [name intersections={of=circulo and path_implementar_prueba,name=intIMPLEMENTARPRUEBA}];
\def \IMPLEMENTARPRUEBAUP {intIMPLEMENTARPRUEBA-1}
\def \IMPLEMENTARPRUEBADOWN {intIMPLEMENTARPRUEBA-2}

    % INTERSECCIÓN PRUEBA FALLANDO
    \path [name intersections={of=circulo and path_prueba_fallando,name=intPRUEBAFALLANDO}];
\def  \PRUEBAFALLANDORIGHT {intPRUEBAFALLANDO-1}
\def \PRUEBAFALLANDOLEFT{intPRUEBAFALLANDO-2}

    % INTERSECCIÓN TRIBUBBLE 1
    \path [name intersections={of=circulo and path_prueba1,name=intPRUEBAUNO}];
\def \TRIBUBBLEUNOUP {intPRUEBAUNO-1}

    \path [name intersections={of=circulo and path_refactor1,name=intREFACTORUNO}];
\def \TRIBUBBLEUNODOWN {intREFACTORUNO-2}

    % INTERSECCIÓN TRIBUBBLE 2
    \path [name intersections={of=circulo and path_prueba2,name=intPRUEBADOS}];
\def \TRIBUBBLEDOSUP {intPRUEBADOS-1}
\def \TRIBUBBLEDOSDOWN {intPRUEBADOS-2}

    % INTERSECCIÓN TRIBUBBLE 3
    \path [name intersections={of=circulo and path_codigo3,name=intCODIGOTRES}];
\def \TRIBUBBLETRESUP {intCODIGOTRES-1}

    \path [name intersections={of=circulo and path_prueba3,name=intPRUEBA3}];
\def \TRIBUBBLETRESDOWN {intPRUEBA3-2}

    % INTERSECCIÓN PRUEBA PASANDO
    \path [name intersections={of=circulo and path_prueba_pasando,name=intPRUEBAPASANDO}];
\def \PRUEBAPASANDOLEFT {intPRUEBAPASANDO-1}
\def \PRUEBAPASANDORIGHT {intPRUEBAPASANDO-2}

    % INTERSECCIÓN REFACTORIZAR
    \path [name intersections={of=circulo and path_refactorizar,name=intREFACTORIZAR}];
\def \REFACTORIZARUP {intREFACTORIZAR-1}
\def \REFACTORIZARDOWN{intREFACTORIZAR-2}

    % INTERSECCIÓN ACEPTACION CLIENTE
    \path [name intersections={of=circulo and path_aceptacion_cliente,name=intACEPTACIONCLIENTE}];
\def \ACEPTACIONCLIENTEUP{intACEPTACIONCLIENTE-1}
\def \ACEPTACIONCLIENTEDOWN{intACEPTACIONCLIENTE-2}



    % LAS FLECHAS EMPEZANDO POR START Y SIGUE EL CAMINO
    \draw [->,bend left=15] (node cs:name=start, anchor=east) to (node cs:name=elegir_us, anchor=west);
    \draw [->,bend left=15] (\ELEGIRUSUP) to (\ESCRIBIRPRUEBASDOWN);
    \draw [->,bend left=15] (\ESCRIBIRPRUEBASUP) to (\IMPLEMENTARPRUEBADOWN);
    \draw [->,bend left=15] (\IMPLEMENTARPRUEBAUP) to (\PRUEBAFALLANDOLEFT);
    \draw [->,bend left=15] (\PRUEBAFALLANDORIGHT) to (\TRIBUBBLEUNOUP);
    \draw [->,bend left=15] (\TRIBUBBLEUNODOWN) to (\TRIBUBBLEDOSUP);
    \draw [->,bend left=15] (\TRIBUBBLEDOSDOWN) to (\TRIBUBBLETRESUP);
    \draw [->,bend left=15] (\TRIBUBBLETRESDOWN) to (\PRUEBAPASANDORIGHT);
    \draw [->,bend left=15] (\PRUEBAPASANDOLEFT) to (\REFACTORIZARDOWN);
    \draw [->,bend left=15] (\REFACTORIZARUP) to (\ACEPTACIONCLIENTEDOWN);
    \draw [->,bend left=15] (\ACEPTACIONCLIENTEUP) to (\ELEGIRUSDOWN);



    % TDD Y ATDD
    \node [above left = 10mm and 10mm of prueba_fallando.center, font=\Large\bfseries] {ATDD};
    \node [above right = 10mm and 10mm of prueba_fallando.center, font=\Large\bfseries] {TDD};
\end{tikzpicture}



\end{document}
22

Galvanic cell

\documentclass{article}

\usepackage[
  figureposition = bottom
]{caption}
\usepackage{chemmacros}
\usepackage{pstricks-add}

\makeatletter
  \providecommand*{\setfloatlocations}[2]{\@namedef{fps@#1}{#2}}
\makeatother
\setfloatlocations{figure}{htbp}

\DeclareCaptionLabelSeparator{adjustment}{:\quad}
\captionsetup{
  font = small,
  labelfont = sc,
  labelsep = adjustment
}

\def\anode{\ch{Zn}}
\def\anodeColour{gray!30}
\def\cathode{\ch{Cu}}
\def\cathodeColour{red!50}

\makeatletter
 \define@key{cell}{anode}{\def\anode{\ch{#1}}}
 \define@key{cell}{anodeColour}{\def\anodeColour{#1}}
 \define@key{cell}{cathode}{\def\cathode{\ch{#1}}}
 \define@key{cell}{cathodeColour}{\def\cathodeColour{#1}}
\makeatother

\newcommand*\cell[4][]{%
  \setkeys{cell}{#1}
  \def\basinWidth{#2 }
  \def\basinHeight{#3 }
  \def\waterHeight{#4}
% Basin
\psline(0,\basinHeight)(0,\waterHeight)
\pscustom[
  fillstyle=solid,
  fillcolor=cyan!70
]{%
  \psline(0,\waterHeight)(\basinWidth,\waterHeight)
  \psline(0,\waterHeight)(0,1)
  \psarc(1,1){1}{180}{270}
  \psline(1,0)(!\basinWidth 1 sub 0)
  \psarc(!\basinWidth 1 sub 1){1}{270}{360}
  \psline(\basinWidth,1)(\basinWidth,\waterHeight)
 \closepath
}
\psline(\basinWidth,\waterHeight)(\basinWidth,\basinHeight)
% Membrane
\psline[
  linestyle=dashed
](!\basinWidth 2 div 0)%
 (!\basinWidth 2 div \waterHeight)
% Cathode
\pspolygon[
  fillstyle=solid,
  fillcolor=\cathodeColour
](!\basinWidth 4 div 1 sub 1)%
 (!\basinWidth 4 div 1 sub \basinHeight 1 sub)%
 (!\basinWidth 4 div 1 add \basinHeight 1 sub)%
 (!\basinWidth 4 div 1 add 1)
\rput(!\basinWidth 4 div \basinHeight 2 div){\cathode\xspace}
% Anode
\pspolygon[
  fillstyle=solid,
  fillcolor=\anodeColour
](!3 \basinWidth mul 4 div 1 sub 1)%
 (!3 \basinWidth mul 4 div 1 sub \basinHeight 1 sub)%
 (!3 \basinWidth mul 4 div 1 add \basinHeight 1 sub)%
 (!3 \basinWidth mul 4 div 1 add 1)
\rput(!3 \basinWidth mul 4 div \basinHeight 2 div){\anode}
% Wires with current
\rput(!\basinWidth 4 div 1 add \basinHeight){$+$}
\psline(!\basinWidth 4 div \basinHeight 1 sub)%
       (!\basinWidth 4 div \basinHeight)
\psarc(!\basinWidth 4 div 1 add \basinHeight){1}{90}{180}
\psline(!\basinWidth 4 div 1 add \basinHeight 1 add)%
       (!\basinWidth 1 sub 2 div \basinHeight 1 add)
\pscircle(!\basinWidth 2 div \basinHeight 1 add){0.5}
\rput(!\basinWidth 2 div \basinHeight 1 add){$U$}
\psline(!3 \basinWidth mul 4 div 1 sub \basinHeight 1 add)%
       (!\basinWidth 1 add 2 div \basinHeight 1 add)
\psarc(!3 \basinWidth mul 4 div 1 sub \basinHeight){1}{0}{90}
\psline(!3 \basinWidth mul 4 div \basinHeight 1 sub)%
       (!3 \basinWidth mul 4 div \basinHeight)
\rput(!3 \basinWidth mul 4 div 1 sub \basinHeight){$-$}
% Electron movement
\rput(!3 \basinWidth mul 1 add 8 div \basinHeight 3 2 div add)%
     {\ch{<-[$\el$]}}
\rput(!5 \basinWidth mul 2 sub 8 div \basinHeight 3 2 div add)%
     {\ch{<-[$\el$]}}
}

\psset{unit = 0.5\psunit}


\begin{document}

% Without optional arguments; the `stardard' version.
\begin{figure}
 \centering
  \begin{pspicture}(15,11.9)
    \cell{15}{10}{8}
  \end{pspicture}
 \caption{Galvanic cell where \anode{} is the anode and \cathode{} is the cathode.}
\end{figure}

% With optional arguments; a `non-stardard' version.
\begin{figure}
 \centering
  \begin{pspicture}(15,11.9)
    \cell[
      anode = Cu,
      anodeColour = red!50,
      cathode = Ag,
      cathodeColour = gray!20
    ]{15}{10}{8}
  \end{pspicture}
 \caption{Galvanic cell where \ch{Cu} is the anode and \ch{Ag} is the cathode.}
\end{figure}

\end{document}

output

22

An alternative way of drawing three dimensional graphs, using pretty much only plain TikZ. This is the intersection between the cone z^2=x^2+y^2 and the cylinder x^2+y^2=2y.

http://i.imgur.com/CQ37s9u.png?1

\documentclass{article}\usepackage{tikz,mathtools}
\tikzset{
    MyPersp/.style={scale=1.4,x={(0.8cm,0.4cm)},y={(-0.8cm,0.4cm)},z={(0cm,1.2cm)}},
    }
\begin{document}\begin{tikzpicture}[MyPersp,axis/.style={->,black,very thin}]
    \def\axissize{3}
    \def\clrcyl{cyan!80!black}
    \def\a{45}% 45 ?

    \def\axissizelowerlim{-2.25}

    \foreach \q in {.2,.4,...,2}
    {
    \pgfmathparse{acos(\q/2)}\edef\value{\pgfmathresult}
    \pgfmathparse{-\value}\edef\minvalue{\pgfmathresult}
    \pgfmathparse{90+\value}\edef\newval{\pgfmathresult}
    \pgfmathparse{90+\minvalue}\edef\newminval{\pgfmathresult}
    \pgfmathparse{\newminval+5}\edef\aux{\pgfmathresult}

    \draw[draw=black] ({\q*cos(\newminval)},{\q*sin(\newminval)},{\q}) 
    \foreach \t in {\newminval,\aux,...,\newval}
    {--({\q*cos(\t)},{\q*sin(\t)},{\q})}; % parts of z^2 = x^2 + y^2, equiradial lines

    \draw[draw=black] ({\q*cos(\newminval)},{\q*sin(\newminval)},{-\q}) 
    \foreach \t in {\newminval,\aux,...,\newval}
    {--({\q*cos(\t)},{\q*sin(\t)},{-\q})};
    }

    % axis lines
    \draw[axis] (0,0,0) -- (\axissize+1,0,0) node[anchor=south west]{$x$};
    \draw[axis] (0,0,0) -- (0,\axissize+1,0) node[anchor=south east]{$y$};
    \draw[axis] (0,0,0) -- (0,0,\axissize+1) node[anchor=south]{$z$};
    \draw[axis] (0,0,0) -- (0,0,{\axissizelowerlim-.25}) node[anchor=north]{$-z$};
    \draw[axis] (0,0,0) -- (0,-\axissize-1,0) node[right=.125in,below=-.025in]{$-y$};
    \draw[axis] (0,0,0) -- (-\axissize-1,0,0) node[below=.075in,left=-.1in]{$-x$};
    \foreach \q in {1,2,...,\axissize}% xy ticks
    {
    \draw (\q,0,-.1) -- (\q,0,.1) node[below=.1in] {$\q$};
    \draw (-\q,0,-.1) -- (-\q,0,.1) node[below=.1in] {$\mathllap{-}\q$};
    \draw (0,\q,-.1) -- (0,\q,.1) node[below=.1in] {$\q$};
    \draw (0,-\q,-.1) -- (0,-\q,.1) node[below=.1in] {$\mathllap{-}\q$};
    }
    \foreach \q in {1,2,...,\axissize}% z ticks
    {
    \draw (0,-.1,\q) -- (0,.1,\q) node[right=.15in,below=-.03in] {$\q$};
    }

    % cyl calcs
    \pgfmathparse{270+\a}\edef\afirst{\pgfmathresult}
    \pgfmathparse{275+\a}\edef\asecond{\pgfmathresult}
    \pgfmathparse{450+\a}\edef\alast{\pgfmathresult}
    \pgfmathparse{90+\a}\edef\bfirst{\pgfmathresult}
    \pgfmathparse{95+\a}\edef\bsecond{\pgfmathresult}
    \pgfmathparse{270+\a}\edef\blast{\pgfmathresult}

    % cylinder
    \foreach \t in {135,315}%
    \draw[\clrcyl, thick] ({cos(\t)},{sin(\t)+1},{\axissizelowerlim})
        --({cos(\t)},{sin(\t)+1},\axissize);
    \draw[\clrcyl,thick] ({cos(\bfirst)},{sin(\bfirst)+1},{\axissizelowerlim})
    \foreach \t in {\bfirst,\bsecond,...,\blast}
    {
    --({cos(\t)},{sin(\t)+1},{\axissizelowerlim})
    };
    \draw[\clrcyl,thick,dashed] ({cos(\afirst)},{sin(\afirst)+1},{\axissizelowerlim})
    \foreach \t in {\afirst,\asecond,...,\alast}    
    {
    --({cos(\t)},{sin(\t)+1},{\axissizelowerlim})
    };

    \draw[\clrcyl, thick] (1,1,\axissize) 
    \foreach \t in {10,20,...,360}
    {--({cos(\t)},{sin(\t)+1},\axissize)}--cycle;

    % line plot
    \draw[\clrcyl,thick] (1,1,{sqrt(2)})
    \foreach \t in {0,5,...,360}    
    {
    --({cos(\t)},{sin(\t)+1},{sqrt(2+2*sin(\t))})
    };
    \draw[\clrcyl,thick] (1,1,{-sqrt(2)})
    \foreach \t in {0,5,...,360}    
    {
    --({cos(\t)},{sin(\t)+1},{-sqrt(2+2*sin(\t))})
    };

\end{tikzpicture}\end{document}
21

Months after, this could be done with nice nested cycles and/or scopes, making the code 2 to 4 times shorter (and paying a bit more attention to colors)...but I still like the output of a tex I wrote very quickly, so I ended up to post it. This was then included in a calculus book for a degree course in Architecture, with great satisfaction for me also.

Riemann sums of a monotonic real function, in pure TikZ (arrows library for axes only):

Riemann sums of a monotonic function TikZ

\documentclass[tikz,multi=false,border=5mm]{standalone}
\usetikzlibrary{arrows}

\begin{document}

\begin{tikzpicture}
    \foreach \x in {0,.5,...,3.5} {%
        \draw[fill=cyan] (\x,0) -- (\x,{.25*(\x+.5)*(\x+.5)}) -- (\x+.5,{.25*(\x+.5)*(\x+.5)}) -- (\x+.5,0);
    }%
    \draw [thick,blue,domain=0:4] plot (\x,{.25*pow(\x,2)});
    \foreach \x in {0,.5,...,3.5} {%
        \draw[fill=orange] (\x,0) -- (\x,.25*\x*\x) -- (\x+.5,.25*\x*\x) -- (\x+.5,0);
    }%
    \draw [->,>=triangle 45] (-.5,0) -- (4.5,0) node[below] {\Large $x$};
    \draw [->,>=triangle 45] (0,-.5) -- (0,4.5) node[left] {\Large $y$};
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
    \foreach \x in {0,1,...,3} {%
        \draw[xshift=-6cm,fill=cyan] (\x,0) -- (\x,{.25*(\x+1)*(\x+1)}) -- (\x+1,{.25*(\x+1)*(\x+1)}) -- (\x+1,0);
    }%
    \draw [xshift=-6cm,thick,blue,domain=0:4] plot (\x,{.25*pow(\x,2)});
    \foreach \x in {0,1,...,3} {%
        \draw[xshift=-6cm,fill=orange] (\x,0) -- (\x,.25*\x*\x) -- (\x+1,.25*\x*\x) -- (\x+1,0);
    }%
    \draw [xshift=-6cm,->,>=triangle 45] (-.5,0) -- (4.5,0) node[below] {\Large $x$};
    \draw [xshift=-6cm,->,>=triangle 45] (0,-.5) -- (0,4.5) node[left] {\Large $y$};
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
    \foreach \x in {0,2} {%
        \draw[xshift=-12cm,fill=cyan] (\x,0) -- (\x,{.25*(\x+2)*(\x+2)}) -- (\x+2,{.25*(\x+2)*(\x+2)}) -- (\x+2,0);
    }%
    \draw [xshift=-12cm,thick,blue,domain=0:4] plot (\x,{.25*pow(\x,2)});
    \foreach \x in {0,2} {%
        \draw[xshift=-12cm,fill=orange] (\x,0) -- (\x,.25*\x*\x) -- (\x+2,.25*\x*\x) -- (\x+2,0);
    }%
    \draw [xshift=-12cm,->,>=triangle 45] (-.5,0) -- (4.5,0) node[below] {\Large $x$};
    \draw [xshift=-12cm,->,>=triangle 45] (0,-.5) -- (0,4.5) node[left] {\Large $y$};
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
    \foreach \x in {0,.25,...,3.75} {%
        \draw[xshift=6cm,fill=cyan] (\x,0) -- (\x,{.25*(\x+.25)*(\x+.25)}) -- (\x+.25,{.25*(\x+.25)*(\x+.25)}) -- (\x+.25,0);
    }%
    \draw [xshift=6cm,thick,blue,domain=0:4] plot (\x,{.25*pow(\x,2)});
    \foreach \x in {0,.25,...,3.75} {%
        \draw[xshift=6cm,fill=orange] (\x,0) -- (\x,.25*\x*\x) -- (\x+.25,.25*\x*\x) -- (\x+.25,0);
    }%
    \draw [xshift=6cm,->,>=triangle 45] (-.5,0) -- (4.5,0) node[below] {\Large $x$};
    \draw [xshift=6cm,->,>=triangle 45] (0,-.5) -- (0,4.5) node[left] {\Large $y$};
\end{tikzpicture}

\end{document}

Update 2015 here we are: two nested cycles, scopes with grouped options, 20 lines of code vs. 48 and the same output (or slightly better):

\documentclass[tikz,multi=false,border=5mm]{standalone}
\usetikzlibrary{arrows}

\begin{document}

\begin{tikzpicture}
\foreach \i/\p/\a in {0/2/2,1/1/3,2/.5/3.5,3/.25/3.75} {%
  \begin{scope}[xshift=6*\i cm,>=triangle 45]
  \foreach \x in {0,\p,...,\a} {%
    \draw[fill=cyan] (\x,0) -- (\x,{.25*pow(\x+\p,2)}) -- (\x+\p,{.25*pow(\x+\p,2)}) -- (\x+\p,0);
    \draw[fill=orange] (\x,0) -- (\x,.25*\x*\x) -- (\x+\p,.25*\x*\x) -- (\x+\p,0);
  }
  \draw [->] (-.5,0) -- ++(5,0) node[below] {\Large $x$};
  \draw [->] (0,-.5) -- ++(0,5) node[left] {\Large $y$};
  \draw [thick,blue,domain=0:4] plot (\x,{.25*pow(\x,2)});
  \end{scope}
}
\end{tikzpicture}

\end{document}
20

It appears that I got the wrong end of the stick with this thread, as my images weren't created in LaTeX (I didn't realise that you could do this).

I've tried to rectify this by seeing if I could convert one of my original images to a LaTeX format from the original .eps files using Latexdraw; however, it turns out that my code is quite long (>0.5 M characters). So far I've only tried this for the nuclide map figure. Unfortunately, Latexdraw doesn't seem to be able to handle the original text very well, and I haven't figured out how to do it myself yet.

Anyway, here's a link to the code for the nuclide map if people want to play around with it. If someone does manage to put the text back, I'd be interested to know how you did it and with what software. For the time being I think I'll stick with SerifDraw and Inkscape to draw and convert my images from .svg to .eps, whilst I'm writing up my thesis, but may look to this for future work.

enter image description here

  • 4
    I really like both images, but the cool thing would be to make them in LaTeX (and Friends). – Manuel Feb 7 '14 at 12:26
  • 10
    This is not a proper answer to the question because the illustrations themselves were not created with LaTeX/PGF/TikZ/Asymptote/Metapost/PSTricks. – marczellm Feb 7 '14 at 12:45
  • It would worthwhile to post the code for the figures otherwise it may not fit well in the list of answers to Q. – texenthusiast Feb 7 '14 at 14:46
  • Ah, sorry. Looks like I completely missed the point of the question. I didn't even realise you could make illustrations like this in LaTeX. – cjms85 Feb 7 '14 at 15:04
  • @cjms85 Thanks for the revision ! – Thomas Feb 7 '14 at 17:54
20

Mexican Hat potential

Spontaneous Symmetry Breaking illustrated for a "mexican hat" potential.

Asymptote code:

import graph3;

size(200,200,IgnoreAspect);

currentprojection=perspective(5,2.7,3);

real f(pair z) {return -abs(z)^2+0.5*abs(z)^4;}

bbox3 b=limits(O,1.75(1,1,1));
currentlight=(1,-1,1);

picture surface=surface(f,(-1.3,-1.3),(1,1),nx=100,palegray);
add(surface);
draw(arc((0,0,-0.5),1,90,60,90,15),ArcArrow);
add(surface(f,(-0.5,-0.5),(0.5,0.5),nx=20,palegray));

yaxis(Label("$\phi^\dagger\phi$",1),b,red,Arrow);
zaxis(Label("$V(\phi^\dagger\phi)$",1),b,red,Arrow);
14

A parameter varying hyperboloid.

enter image description here

\documentclass[pstricks,border=0pt]{standalone}
\usepackage{pst-solides3d}
%%%%%%%%%%%%%%%%%%
\begin{document}
\psset{unit=.15\columnwidth,viewpoint=10 45 25 rtp2xyz,linewidth=.4pt,Decran=10,lightsrc=3 2 5,lightintensity=2}
\def\l{1}
\multido{\r=0+0.051579}{20}{
\begin{pspicture}(-3,-3)(3,3)
\def\h{.99999 \r\space sub}
\defFunction{regulusx}(u,v){v}
    {1 \h\space sub v 2 exp mul 1 \h\space sub 1 \h\space add mul \h\space mul add     \h\space u Cos 2 exp mul 1 \h\space add u Sin 2 exp mul add    div   sqrt      u Cos mul}
    {1 \h\space sub v 2 exp mul 1 \h\space sub 1 \h\space add mul \h\space mul add     \h\space u Cos 2 exp mul 1 \h\space add u Sin 2 exp mul add    div   sqrt      u Sin mul}
\psSolid[object=surfaceparametree,linewidth=.1pt,base=0 2 pi mul \l\space neg \l\space,fillcolor=yellow!50,incolor=yellow!50,function=regulusx,ngrid=40 20]%    
\end{pspicture}}
\multido{\r=0+0.051579}{20}{
\begin{pspicture}(-3,-3)(3,3)
\def\h{0.01999 \r\space add}
\defFunction{regulusz}(u,v)
    {1 \h\space sub v 2 exp mul 1 \h\space sub 1 \h\space add mul \h\space mul add     \h\space u Cos 2 exp mul 1 \h\space add u Sin 2 exp mul add    div   sqrt      u Sin mul}
    {1 \h\space sub v 2 exp mul 1 \h\space sub 1 \h\space add mul \h\space mul add     \h\space u Cos 2 exp mul 1 \h\space add u Sin 2 exp mul add    div   sqrt      u Cos mul}
    {v}
\psSolid[object=surfaceparametree,linewidth=.1pt,base=0 2 pi mul \l\space neg \l\space,fillcolor=yellow!50,incolor=yellow!50,function=regulusz,ngrid=40 20]%    
\end{pspicture}}
\multido{\r=0+0.051579}{20}{
\begin{pspicture}(-3,-3)(3,3)
\def\h{0.99999 \r\space sub}
\defFunction{regulusz}(u,v)
    {1 \h\space sub v 2 exp mul 1 \h\space sub 1 \h\space add mul \h\space mul add     \h\space u Cos 2 exp mul 1 \h\space add u Sin 2 exp mul add    div   sqrt      u Sin mul}
    {1 \h\space sub v 2 exp mul 1 \h\space sub 1 \h\space add mul \h\space mul add     \h\space u Cos 2 exp mul 1 \h\space add u Sin 2 exp mul add    div   sqrt      u Cos mul}
    {v}
\psSolid[object=surfaceparametree,linewidth=.1pt,base=0 2 pi mul \l\space neg \l\space,fillcolor=yellow!50,incolor=yellow!50,function=regulusz,ngrid=40 20]%    
\end{pspicture}}
\multido{\r=0+0.051579}{20}{
\begin{pspicture}(-3,-3)(3,3)
\def\h{.01999 \r\space add}
\defFunction{regulusx}(u,v){v}
    {1 \h\space sub v 2 exp mul 1 \h\space sub 1 \h\space add mul \h\space mul add     \h\space u Cos 2 exp mul 1 \h\space add u Sin 2 exp mul add    div   sqrt      u Cos mul}
    {1 \h\space sub v 2 exp mul 1 \h\space sub 1 \h\space add mul \h\space mul add     \h\space u Cos 2 exp mul 1 \h\space add u Sin 2 exp mul add    div   sqrt      u Sin mul}
\psSolid[object=surfaceparametree,linewidth=.1pt,base=0 2 pi mul \l\space neg \l\space,fillcolor=yellow!50,incolor=yellow!50,function=regulusx,ngrid=40 20]%    
\end{pspicture}}
\end{document}
13

The intersection between a surface and a plane:

intersection

\documentclass{scrartcl}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[domain=0.01:30]
\addplot3[surf] {min(0.,(1-0.3)*e^(-x*(y/100)*(1-0.3))-e^(-x*(y/100))};
\addplot3[surf] {max(0.,(1-0.3)*e^(-x*(y/100)*(1-0.3))-e^(-x*(y/100)))};
\addplot3[domain=4:30,samples=80,samples y=0,mark=none,black, opacity=0.5,thick]({x},{118.89/x},{0.});
\addplot3[domain=0:30,samples=80,samples y=0,mark=none,black, opacity=0.5,thick]({x},{30.},{max(0.,(1-0.3)*e^(-x*(30./100)*(1-0.3))-e^(-x*(30./100)))});
\addplot3[domain=0:30,samples=80,samples y=0,mark=none,black, opacity=0.5,thick]({x},{0.},{max(0.,(1-0.3)*e^(-x*(0./100)*(1-0.3))-e^(-x*(0./100)))});
\addplot3[domain=0:30,samples=80,samples y=0,mark=none,black, opacity=0.5,thick]({x},{0.},{min(0.,(1-0.3)*e^(-x*(0./100)*(1-0.3))-e^(-x*(0./100)))});
\addplot3[domain=0:30,samples=80,samples y=0,mark=none,black, opacity=0.5,thick]({0.},{x},{max(0.,(1-0.3)*e^(-0.*(x/100)*(1-0.3))-e^(-0.*(x/100)))});
\addplot3[domain=0:30,samples=80,samples y=0,mark=none,black, opacity=0.5,thick]({30.},{x},{max(0.,(1-0.3)*e^(-30.*(x/100)*(1-0.3))-e^(-30.*(x/100)))});
\addplot3[domain=0:30,samples=80,samples y=0,mark=none,black, opacity=0.5,thick]({30.},{x},{min(0.,(1-0.3)*e^(-30.*(x/100)*(1-0.3))-e^(-30.*(x/100)))});
\end{axis}
\end{tikzpicture}
\end{document}

(originally posted here https://tex.stackexchange.com/a/73989/1871)

13

Radioactive dacay

Note: There is a screenshot of only the first half life of a nucleus but there are five half lifes for each version (but it can very easily be changed).

First version

\documentclass[
  dvipsnames
]{article}

\usepackage{lmodern}
\usepackage[
  hmargin = 2.4cm,
  vmargin = 3cm
]{geometry}
\usepackage{fancyhdr}
\usepackage{pst-plot}
\usepackage[
  locale = DE
]{siunitx}
\usepackage{xfp}
\usepackage{xfrac}
\usepackage{totcount}

%%% Constants %%%

\def\HalveringerA{\fpeval{\Halveringer-1}}
\def\HalveringerB{\fpeval{\Halveringer+1}}
\def\konstA{\fpeval{10*2^(-\iA)}}
\def\konstI{\num{\fpeval{10*\konstA}}}
\def\konstB{\fpeval{2^(-\Halveringer)}}
\def\konstC{\fpeval{16*2^(-\iA)}}
\def\konstD{\fpeval{16-\konstC}}
\def\konstE{\fpeval{2*\Halveringer+0.25}}
\def\konstF{\fpeval{\konstE+0.25}}
\def\konstG{\fpeval{\konstE-0.25}}
\def\konstH{\fpeval{\konstE+0.55}}

%%% Definitions %%%

\def\radioaktivt{%
  \pscircle[
    fillstyle = solid,
    fillcolor = yellow,
    linestyle = none
  ](0,0){0.125}
  \pswedge*(0,0){0.125}{0}{60}
  \pswedge*(0,0){0.125}{120}{180}
  \pswedge*(0,0){0.125}{240}{300}
  \pscircle*[
    linecolor = yellow
  ](0,0){0.0375}
  \pscircle*(0,0){0.025}
}
\def\ikkeradioaktivt{%
  \pscircle*[
    linecolor = SeaGreen
  ](0,0){0.125}
}

\newcommand*\halveringer[1]{%
 \def\Halveringer{#1}
  \begin{pspicture}(-1.75,-0.7)(\konstH,11.05)
    \multido{\iA = 0+1, \rC = 0.25+2}{\Halveringer}{%
      \multido{\rA = \rC+0.5}{4}{%
        \multido{\rB = 0.27+0.635}{\konstC}{%
          \rput(\rA,\rB){\radioaktivt}%
        }%
      }%
    }
    \multido{\iA = 0+1, \rC = 0.25+2}{\Halveringer}{%
      \multido{\rA = \rC+0.5}{4}{%
        \multido{\rB = 9.795+-0.635}{\konstD}{%
          \rput(\rA,\rB){\ikkeradioaktivt}%
        }%
      }%
    }
    \multido{\iA = 0+1}{\Halveringer}{%
      \psline(!2   \iA\space mul     \konstA)%
             (!2 1 \iA\space add mul \konstA)%
             (!2 2 \iA\space mul add \konstA\space 2 div)%
    }
    \psline(!2 \Halveringer\space mul 10 \konstB\space mul)%
           (!2 \Halveringer\space mul 0)
    \psaxes[
      ticks = none,
      labels = none,
      arrowinset = 0.05,
      arrowscale = 1.6,
      arrowlength = 1.8
    ]{->}(0,0)(-0.3,-0.3)(\konstF,10.5)[$t$,0][Radioactive nuclei~(\si{\percent}),90]
    \psplot[
      algebraic,
      linecolor = red,
      linewidth = 1.5pt
    ]{0}{\konstG}{10*0.5^(0.5*x)}
    \psxTick(2){T_{\sfrac{1}{2}}}
    \multido{\iA = 4+2, \iB = 2+1}{\HalveringerA}{%
      \psxTick(\iA){\iB \cdot T_{\sfrac{1}{2}}}%
    }
    \multido{\iA = 0+1}{\HalveringerB}{%
      \psyTick(\konstA){\konstI}%
    }%
  \end{pspicture}%
}

\pagestyle{fancy}
\renewcommand*\headrulewidth{0pt}
\setlength\headheight{14.5pt}
\lhead{}
\rhead{}
\regtotcounter{page}
\cfoot{
  \ifnum \totvalue{page} > 1 \relax
    \thepage
  \else
%
  \fi
}

\begin{document}

%\begin{figure}[htbp]
% \centering
%  \begin{pspicture}(-2.4,-1.4)(2.4,2.9)
%    \pspolygon[
%      fillstyle = solid,
%      fillcolor = yellow,
%      linewidth = 5\pslinewidth
%    ](2.875;-30)(2.875;90)(2.875;210)
%    \pswedge*(0,0){1.25}{0}{60}
%    \pswedge*(0,0){1.25}{120}{180}
%    \pswedge*(0,0){1.25}{240}{300}
%    \pscircle*[
%      linecolor = yellow
%    ](0,0){0.375}
%    \pscircle*(0,0){0.25}
%  \end{pspicture}
%\end{figure}
%
%\begin{figure}[htbp]
% \centering
%  \begin{pspicture}(-1.8,-1.9)(1.8,1.9)
%    \psframe[
%      fillstyle = solid,
%      fillcolor = yellow,
%      linecolor = gray
%    ](-2,-2)(2,2)
%    \pswedge*(0,0){1.75}{0}{60}
%    \pswedge*(0,0){1.75}{120}{180}
%    \pswedge*(0,0){1.75}{240}{300}
%    \pscircle*[
%      linecolor = yellow
%    ](0,0){0.5}
%    \pscircle*(0,0){0.35}
%  \end{pspicture}
%\end{figure}
%\newpage

\multido{\iK = 1+1}{5}{%
  \begin{center}
    \halveringer{\iK}
  \end{center}
}

\end{document}

output1

Second version

\documentclass[
  dvipsnames
]{article}

\usepackage{lmodern}
\usepackage[
  hmargin = 2.4cm,
  vmargin = 3cm
]{geometry}
\usepackage{fancyhdr}
\usepackage{
  pst-grad,
  pst-plot
}
\usepackage[
  locale = DE
]{siunitx}
\usepackage{xfp}
\usepackage{xfrac}
\usepackage{totcount}

%%% Constants %%%

\def\maerkerX{\fpeval{1.5*\i+0.75}}
\def\maerkerYa{\fpeval{10*2^(-\i)}}
\def\maerkerYb{\num{\fpeval{100*2^(-\i)}}}

\def\halveringerB{\fpeval{\Halveringer-1}}
\def\halveringerC{\fpeval{\Halveringer+1}}
\def\konstA{\fpeval{1.5*\i+0.25}\space}
\def\konstB{\fpeval{32*2^(-\i)}}
\def\konstC{\fpeval{32-\konstB}}
\def\konstD{\fpeval{1.5*\halveringerC+0.75}}
\def\konstE{\fpeval{\konstD-0.75}}
\def\konstF{\fpeval{\konstD+0.3}}

%%% Definitions %%%

\def\radioaktivt{%
  \psscalebox{0.0125}{%
    \pscircle[
      fillstyle = solid,
      fillcolor = yellow,
      linestyle = none
    ](0,0){5}
    \pswedge*(0,0){5}{0}{60}
    \pswedge*(0,0){5}{120}{180}
    \pswedge*(0,0){5}{240}{300}
    \pscircle*[
      linecolor = yellow
    ](0,0){1.5}
    \pscircle*(0,0){1}
  }
}

\def\ikkeradioaktivt{%
  \pscircle*[
    linecolor = SeaGreen
  ](0,0){0.0625}
}

\def\henfald{rand 301 mod 50 div round 50 div }
\def\simpel#1{!#1 \henfald add \henfald \i\space 5 mul 16 div add 0.121 add }

\newcommand*\halveringer[1]{%
 \def\Halveringer{#1}
  \begin{pspicture}(-1.75,-0.65)(\konstF,11.3)
    \psframe[
      linestyle = none,
      fillstyle = gradient,
      gradangle = 45,
      gradmidpoint = 1,
      gradbegin = gray!80,
      gradend = gray!30
    ](0,0)(\konstE,10.25)
    \multido{\i = 0+1}{\halveringerC}{%
      \psframe[
        dimen = middel,
        linecolor = NavyBlue,
        linewidth = 1pt,
        fillstyle = gradient,
        gradangle = 90,
        gradmidpoint = 1,
        gradbegin = NavyBlue!50,
        gradend = white
      ](\konstA,0)(!\konstA 1 add \maerkerYa)%
    }
    \multido{\i=0+1}{\halveringerC}{%
      \psframe[
        dimen = middel,
        linecolor = NavyBlue,
        linewidth = 1pt,
        fillstyle = gradient,
        gradangle = 90,
        gradmidpoint = 0,
        gradbegin = SeaGreen!30,
        gradend = white
      ](\konstA,10)(!\konstA 1 add \maerkerYa)%
    }
    \multido{\i = 0+1}{\halveringerC}{%
      \rput(\konstA,0){%
        \multido{\i = 0+1}{\konstB}{%
          \rput{!\henfald 777 mul}(\simpel{0.125}){\radioaktivt}
          \rput{!\henfald 777 mul}(\simpel{0.375}){\radioaktivt}
          \rput{!\henfald 777 mul}(\simpel{0.625}){\radioaktivt}
          \rput{!\henfald 777 mul}(\simpel{0.875}){\radioaktivt}%
        }%
      }
      \rput(\konstA,\maerkerYa){%
        \multido{\i = 0+1}{\konstC}{%
          \rput(\simpel{0.125}){\ikkeradioaktivt}
          \rput(\simpel{0.375}){\ikkeradioaktivt}
          \rput(\simpel{0.625}){\ikkeradioaktivt}
          \rput(\simpel{0.875}){\ikkeradioaktivt}%
        }%
      }%
    }
    \psaxes[
       ticks = none,
       labels = none,
       arrowinset = 0.05,
       arrowscale = 1.6,
       arrowlength = 1.8
    ]{->}(0,0)(-0.3,-0.3)(\konstD,10.75)[$t$,0][Radioactive nuclei~(\si{\percent}),90]
    \psplot[
      algebraic,
      linecolor = red,
      linewidth = 1.5pt
    ]{0.75}{\konstE}{10*0.5^(2*(x-0.75)/3)}
    \psxTick(0.75){\text{start}}
    \ifnum\Halveringer>0\relax
      \psxTick(2.25){T_{\sfrac{1}{2}}}
      \multido{\i = 2+1}{\halveringerB}{%
        \psxTick(\maerkerX){\i \cdot T_{\sfrac{1}{2}}}%
      }
      \multido{\i = 0+1}{\halveringerC}{%
        \psyTick(\maerkerYa){\maerkerYb}%
      }%
    \fi%
  \end{pspicture}%
}

\pagestyle{fancy}
\renewcommand*\headrulewidth{0pt}
\setlength\headheight{14.5pt}
\lhead{}
\rhead{}
\regtotcounter{page}
\cfoot{
  \ifnum \totvalue{page} > 1 \relax
    \thepage
  \else
%
  \fi
}

\begin{document}

\multido{\iK = 0+1}{6}{%
  \begin{center}
    \halveringer{\iK}
  \end{center}
}

\end{document}

output2

P.S. The macro names are is Danish but I hope it is understandable nonetheless.

  • How do you compile it? I've tried pdflatex but got lots of errors. I've tried latex and then dvipdf but the output it's not what I've expected. – Nico Feb 6 '14 at 18:09
  • 1
    @Nico latex --> dvips --> ps2pdf. – Svend Tveskæg Feb 7 '14 at 6:16
13

Some of the images took from my thesis. Intead of directly submitting the code, I will include a link to the line in the repo that contains the image in tikz.

But, the drone is actually an SVG included in the tikz figure, since it comes from CAD drawing...


Single coil in a magnetic field

enter image description here

source


A perception-action agent

enter image description here

source


A range finder lobe

enter image description here

source


Drone searching strategy

enter image description here

source


Simulation of the drone flight

enter image description here

source


Range finder input during simulation (one RF for each motor)

enter image description here

source


Searching for the target (probability varying during time)

enter image description here

source


A brand new image: Orbiting debris

enter image description here

source


Another entry! Evolutionary Algorithm

enter image description here

source

12

Here are some basic physics diagrams I created using Tikz in response to various physics forum questions online. I have just started using Tikz and hope these samples might be helpful to other beginners requiring to create these types of diagrams also.  

Gas Spring Problem

Gas spring

\documentclass[landscape]{article}

\usepackage{tikz}
\usepackage[margin=1in]{geometry}

\usetikzlibrary{arrows.meta}
\usetikzlibrary{scopes}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}

\begin{document}

\definecolor{info_color}{RGB}{250,252,113}

\begin{tikzpicture}
    [scale=1.4,
    node font=\Large,
    box/.style={line width=1pt},
    dashed line/.style={line width=0.5pt, dash pattern=on 4pt off 2pt},
    dashed line light/.style={line width=0.2pt, dash pattern=on 4pt off 2pt,black!30!white},
        gas spring/.style={line width=2pt,gas spring color},
    information text/.style={rounded corners,fill=info_color,inner sep=1ex}]

    \colorlet{gas spring color}{green!50!black}

    % draw box with lid
    \draw [box] (0,0) coordinate (O) -- (8,0) -- (8,-4) -- (0,-4) -- cycle;
    \node at (-0.4,0.2) {O};
    \draw [box] (0,0) -- (30:8) coordinate[pos=0.42] (Q) node[pos=0.42,above left=2pt] {Q};
    \begin{scope}[shift={(120:2)}]
    \draw[{Stealth[length=0.3cm]}-{Stealth[length=0.3cm]}] (0,0) -- (30:8) node[pos=0.5,fill=white,inner sep=5pt] {D}; 
    \end{scope}
    \draw[dashed line light] (0,0) -- (120:2);
    \draw[dashed line light] (30:8) -- +(120:2);
    \draw[-{Stealth[length=0.3cm]}] (0,0) -- (1.5,0) arc [start angle=0, end angle=30, radius=1.5];
    \draw[] (15:1) node {\LARGE $\theta$};
    \path (0,0) -- (30:8) node[pos=0.9,sloped,above=5pt] {\LARGE \bfseries LID};
    \path (0,0) -- (8,0) node[pos=0.9,sloped,above=5pt] {\LARGE \bfseries BOX};

    % draw gas spring with dimensions
    \draw[gas spring] (Q) -- (1.7,-1.3) coordinate (P) node[below right=1pt,black] {P};
    \foreach \point in {P,Q} \fill [gas spring color,opacity=.5] (\point) circle (3pt);
    \draw[dashed line] (O |- P) node[below left=2pt]{S} coordinate (S) -- (P) node[pos=0.5,below=4pt] {$c$}; 
    \draw[dashed line] (O -| P) -- (P); 
    \path (O) -- (S) node[pos=0.5,left=2pt] {$b$};
    \path (O) -- (Q) node[pos=0.5,above left=2pt] {$a$};
    \path (P) -- (Q) node[pos=0.65,left=0pt] {$L$};

    % draw lever arm
    \draw[dashed line, blue, name path=perpendic] (0,0) -- (-20:6) node[pos=0.2,below left=-2pt] {$h$};
    \path[name path=PQ] (P) -- (Q);
    \draw[name intersections={of=perpendic and PQ,by=right angle},red,line width=2pt] ($(O)!1.14!(right angle)$) -- ([turn]90:0.25) -- ([turn]90:0.25);

    % forces
    \coordinate (F1) at ($(P)!0.45!(Q)$);
    \coordinate (F2) at ($(P)!0.86!(Q)$);
    \draw[-{Stealth[length=0.3cm]},red,line width=2pt] ($(F1) + (0.3,0)$) -- ($(F2) + (0.3,0)$) node[pos=0.5,below right=-4pt] {$F_{s}$};
    \coordinate (F1) at (30:4);
    \draw[-{Stealth[length=0.3cm]},red,line width=2pt] ($(F1) + (0,2)$) -- ($(F1) + (0,0.3)$) node[pos=0.5,left=0pt] {$F_{g}$};
    \coordinate (F1) at (16:8.2);
    \draw[-{Stealth[length=0.3cm]},red,line width=2pt] (F1) -- +(120:1.5) node[pos=0.5,right=0pt] {$F_{l}$};

    % information
    \draw[shift={(9.5,2)}] node[right,text width=10cm,information text] {
    \textbf{Forces on lid at equilibrium}
    \vspace{1.3ex}
        \begin{description}
        \boldmath
        \item[$F_{s}$] = force at Q (parallel to gas spring PQ due to freely moving pin joint at Q)
        \item[$F_{g}$] = total weight of lid acting at lid's center of gravity
        \item[$F_{l}$] = hand force applied to lid
        \item[$h$] = moment arm of $F_{s}$
        \item[$a$, $b$, $c$] = fixed mounting positions
        \item[$L$] = spring length (variable)
        \end{description}
    };
\end{tikzpicture}

\end{document}

 


Torricelli's Law

enter image description here

\documentclass[landscape]{article}

\usepackage{tikz}
\usepackage[margin=1in]{geometry}

\usetikzlibrary{arrows.meta}
\usetikzlibrary{scopes}

\newcommand{\fluidcontainer}{
\begin{scope}
\draw [rounded corners, line width=2pt] (0, 7) -- (0,0) -- (6,0) -- (6,2) -- (7,2);
\draw [rounded corners, line width=2pt] (7,3) -- (6,3) -- (6,7); 

\draw[-{Stealth[length=0.25cm]},blue_annot] (3,8.5) -- (3,7.5) node[pos=0.5,left] {\large $p_{1}$} ;
\draw[-{Stealth[length=0.25cm]},blue_annot] (8.5,2.8) -- (7.5,2.8) node[pos=0.5,above] {\large $p_{2}$} ;

\draw[red_annot] (1,8) node[above] {\large $R_{1}$} to [bend left=15] (1.5,6.6);
\draw[red_annot] (7.5,4) node[above] {\large $R_{2}$} to [bend right=20] (6.4,2.5);
\node[red_annot] at (3,3.5) {\Large $R_{3}$};

\draw[{Stealth[length=0.3cm]}-{Stealth[length=0.3cm]}] (-1,6.8) -- (-1,2.5) node[pos=0.5,left] {$h$}; 

\draw[-{Stealth[length=0.2cm]}] (7,7.5) -- (7,6.8);
\draw[-{Stealth[length=0.2cm]}] (7,5.7) -- (7,6.4);
\node at (7.5,6.6) {\large $\Delta s_{1}$};

\draw[-{Stealth[length=0.2cm]}] (5.3,1) -- (6,1);
\draw[-{Stealth[length=0.2cm]}] (7.5,1) -- (6.8,1);
\node at (6.5,0.7) {\large $\Delta s_{2}$};
\end{scope}
}


\begin{document}

\definecolor{fluid_color}{RGB}{255,247,153}
\definecolor{blue_annot}{RGB}{0,0,255}
\definecolor{red_annot}{RGB}{255,0,0}
\definecolor{level_color}{RGB}{0,190,0}

\begin{tikzpicture}[scale=1,level dashed/.style={level_color, line width=1pt, dash pattern=on 4pt off 2pt},level solid/.style={level_color, line width=2pt}]

\begin{scope}[shift={(0cm,0cm)}]
\path [fill=fluid_color] (0,0) -- (6,0) -- (6,6.8) -- (0,6.8) -- cycle;
\draw[level solid] (0,6.8) -- (6,6.8);
\draw[level dashed] (0,6.4) -- (6,6.4);
\draw[level solid] (6,1.5) -- (6,3.5);
\draw[level dashed] (6.8,2) -- (6.8,3);
\fluidcontainer;
\draw[-{Stealth[length=0.25cm]},blue_annot] (5,6.8) -- (5,5) node[pos=0.5,left] {\large $v_{1}$} ;
\draw[-{Stealth[length=0.25cm]},blue_annot] (6,2.4) -- (7.7,2.4) node[pos=0.75,below] {\large $v_{2}$} ;
\end{scope}

\begin{scope}[shift={(11cm,0cm)}]
\path [fill=fluid_color] (0,0) -- (6,0) -- (6,2) -- (6.8,2) -- (6.8,3) -- (6,3) -- (6,6.4) -- (0,6.4) -- cycle;
\draw[level dashed] (0,6.8) -- (6,6.8);
\draw[level solid] (0,6.4) -- (6,6.4);
\draw[level dashed] (6,1.5) -- (6,3.5);
\draw[level solid] (6.8,2) -- (6.8,3);
\fluidcontainer;
\draw[-{Stealth[length=0.25cm]},blue_annot] (5,6.4) -- (5,4.6) node[pos=0.5,left] {\large $v_{1}$} ;
\draw[-{Stealth[length=0.25cm]},blue_annot] (6.8,2.4) -- (8.5,2.4) node[pos=0.7,below] {\large $v_{2}$} ;
\end{scope}

\node at (8.5,-1.5) {\Large \textbf{Fig. 1} \hspace{0.2cm} Fluid before and after time $\Delta t$. };

\end{tikzpicture}

\end{document}

 


Tightrope Pole

enter image description here

\documentclass[a4paper]{article}

\usepackage{tikz}
\usepackage[margin=1in]{geometry}

\usetikzlibrary{arrows.meta}
\usetikzlibrary{scopes}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}[node font=\LARGE]
% walker
\begin{scope}[rotate around={-25:(0.5,0)}]
\draw[line width=1.2pt] (0,0) -- ++(1,0) -- ++(0,16) node[pos=0.51,right=0.5em] {Walker C of G} node[pos=0.85,right=1em] {Walker} -- ++(-1,0) -- cycle;
\filldraw (0.5,8) coordinate (CG) circle (3pt);
\draw[-{Stealth[length=0.3cm]},green!60!black,rotate around={-10:(0.5,0)}] (0.5,13) arc [start angle=90, end angle=65, radius=13] node[pos=0.55,above=1em] {$\alpha$};
\end{scope}

% rope
\draw[fill=blue!20,draw=blue!70,line width=3pt] (0.5,0) circle (1) node[below left=2em] {Rope};
\draw[fill] (0.5,0) circle (3pt);

% guidelines
\draw[line width=.5pt,dash pattern=on 4pt off 2pt,black!30!white] (0.5,-6) -- +(0,20);
\draw[line width=.5pt,dash pattern=on 4pt off 2pt,black!30!white] (CG |- 0,-6) -- +(0,20);
\draw[{Stealth[length=0.3cm]}-{Stealth[length=0.3cm]}] (0.5,-4) -- (CG |- 0,-4) node[pos=0.5,below=3pt] {$r$}; 
\draw[-{Stealth[length=0.3cm]}] (0.5,5) arc [start angle=90, end angle=65, radius=5];
\draw (0.5,0) +(81:3.5) node {\Huge $\theta$};

% force
\draw[-{Stealth[length=0.5cm]},red,line width=3pt] ($(CG) + (0,-2)$) -- +(0,-4) node[pos=0.5,right=3pt] {${F = m_{w}g}$};

% Fig
\node[right] at (6,-4) {\textbf{Fig. 1} \hspace{0.2cm} Walker without pole. };
\end{tikzpicture}

\end{document}

 


Tightrope Pole 2

enter image description here

\documentclass[landscape,a4paper]{article}

\usepackage{tikz}
\usepackage[hmargin=1in, left=0.5in, bottom=1in, top=.7in]{geometry}

\usetikzlibrary{arrows.meta}

\begin{document}

\begin{tikzpicture}[node font=\LARGE,scale=0.5]
% walker
\draw[line width=1.2pt] (0,0) -- ++(1,0) -- ++(0,16) -- ++(-1,0) node[xshift=-2.2em,yshift=0.6em] {Walker} -- cycle;
\draw[green!60!black,{Stealth[length=0.3cm]}-{Stealth[length=0.3cm]}] (3,0) -- +(0,16) node[pos=0.75,fill=white,inner sep=7pt] {H};

% rope
\draw[fill=blue!20,draw=blue!70,line width=3pt] (0.5,0) circle (1) node[below left=1.7em] {Rope};
\draw[fill] (0.5,0) circle (3pt);

% pole
\draw[line width=1.2pt] (2,8) -- ++(24,0) node[pos=0.5,above=3pt] {$\frac{1}{2}L$} node[pos=0.95,below=6pt] {pole};
\draw[line width=1.2pt] (-2,8) -- ++(-24,0) node[pos=0.5,above=3pt] {$\frac{1}{2}L$} node[pos=0.95,below=6pt] {pole};

% tilt arrows
\draw[-{Stealth[length=0.3cm]},red] (-24,10) to [bend left=15] +(2,4);
\draw[-{Stealth[length=0.3cm]},red] (-24,4) to [bend right=15] +(2,-4);
\draw[-{Stealth[length=0.3cm]},red] (24,10) to [bend right=15] +(-2,4);
\draw[-{Stealth[length=0.3cm]},red] (24,4) to [bend left=15] +(-2,-4);

% Fig
\node[right] at (11,-2) {\textbf{Fig. 2} \hspace{0.2cm} Walker with pole. };
\end{tikzpicture}

\end{document}

 


Moon Synodic Period

enter image description here

 

\documentclass[a4paper,portrait]{article}

\usepackage{tikz}
\usepackage[margin=0.3in]{geometry}

\usetikzlibrary{scopes}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}

\begin{document}

\begin{tikzpicture} [
    scale=0.7,
    node font=\LARGE,
    dashed axis/.style={dash pattern=on 4pt off 2pt},
    moon line/.style={dash pattern=on 8pt off 4pt},
    information text/.style={rounded corners, fill=Info Color, inner sep=1ex}
]

\definecolor{Earth Color}{HTML}{358af3};
\definecolor{Sun Color}{HTML}{fffc00};
\definecolor{Moon Color}{HTML}{ddbd4c};
\definecolor{Info Color}{HTML}{eeeeee};

\def\SunPosition{16};

% draw Earth xy-frame (fixed direction Earth frame), and the Earth at the origin
\fill (0, 0) [Earth Color, opacity=.6] circle (1cm);
\draw[{Stealth[length=0.3cm]}-{Stealth[length=0.3cm]}] (-4, 0) -- (16, 0) node [right=1em] {$x$};
\draw[{Stealth[length=0.3cm]}-{Stealth[length=0.3cm]}] (0, -4) -- (0, 16) node [above=1em] {$y$};
\filldraw (0, 0) circle (3pt);
\path (0, 0) node [shift={(-3.5, 1.6)}, anchor=north west] {\Large EARTH};

% draw Earth x'y'-frame (Earth frame directed at Sun, ie 'Noon-frame'), and the Sun on the y'-axis
\begin{scope}[rotate around={-55:(0, 0)}]
\fill (0, \SunPosition) coordinate (S) [Sun Color, opacity=.7] circle (1.5cm);
\draw[{Stealth[length=0.3cm]}-{Stealth[length=0.3cm]}] (-4, 0) -- (10, 0) coordinate (X') node [right=1em] {$x'$};
\draw[{Stealth[length=0.3cm]}-{Stealth[length=0.3cm]}] (0, -4) -- (0, 24) node [above=1em] {$y'$};
\filldraw (0, \SunPosition) circle (3pt);
\end{scope}
\draw[line width=2pt] (0.6,0) -- ($(0,0)!(0.6,0)!(S)$);
\draw[line width=2pt] (0.6,0) -- ($(0,0)!(0.6,0)!(X')$);

% draw arrow for Earth's orbital motion
\draw[-{Stealth[length=0.6cm]},line width=3pt,Earth Color,rotate around={203:(S)}] ($(S) + (21,0)$) arc [start angle=0, end angle=10, radius=21];

% draw Sun's x''y''-frame (fixed direction Sun frame)
\begin{scope}[shift={(S)}]
\draw[{Stealth[length=0.3cm]}-{Stealth[length=0.3cm]}, dashed axis] (-4, 0) -- (4, 0) node [right=1em] {$x''$};
\draw[{Stealth[length=0.3cm]}-{Stealth[length=0.3cm]}, dashed axis] (0, -4) -- (0, 8) node [above=1em] {$y''$};
\draw[-{Stealth[length=0.3cm]}, green!60!black] (2.5, 0) arc [start angle=0, end angle=215, radius=2.5] node[pos=0.65,above left] {$\pi + \theta$};
\path (0, 0) node [shift={(2.2,-1.2)}] {\Large SUN (fixed)};
\end{scope}

% draw Moon
\begin{scope}[rotate around={-20:(0, 0)}]
\fill (0, 7) coordinate (M) [Moon Color, opacity=.8] circle (.7cm);
\draw[moon line] (0, 0) -- (0, 15);
\filldraw (0, 7) circle (3pt);
\node [shift={(-0.8,1)}] at (0, 7) {\Large MOON};
\draw[-{Stealth[length=0.6cm]},line width=3pt,Moon Color,rotate around={-10:(0, 0)}] (0, 9.5) arc [start angle=90, end angle=110, radius=9.5];
\end{scope}

% draw various angles including Moon phase angle psi
\draw[-{Stealth[length=0.3cm]},green!60!black] (2, 0) arc [start angle=0, end angle=70, radius=2] node[pos=0.7,above right=-4pt] {$\phi$};
\draw[-{Stealth[length=0.3cm]},green!60!black] (3.5, 0) arc [start angle=0, end angle=35, radius=3.5] node[pos=0.45,above right=-2pt] {$\theta$};
\draw[-{Stealth[length=0.3cm]}, red!80!black,rotate around={-55:(0, 0)}] (5, 0) arc [start angle=0, end angle=125, radius=5] node[pos=0.3, below right=-2pt] {$\psi$};

% draw information box
\draw[shift={(10, -11)}] node[above right, text width=7cm,information text] {
    \Large
    {\boldmath
    \textbf{\underline{Moon Phase Angle $\psi$}} }

    \vspace{1ex}
    \large
    \begin{description}
    {\boldmath
    \item[$xy$-axes]= fixed direction but moving frame centered on Earth
    \item[$x'y'$-axes]= moving 'noon' frame centered on Earth (always points at Sun)
    \item[$x''y''$-axes]= fixed frame of Sun
    \item[$\psi$]= moon phase angle =} $\pi/2 + (\phi - \theta)$
    \end{description}
};

\node[above right] at (-5, -11) {\Large \textbf{Fig. 1} \hspace{0.1cm} Moon Phase Angle};

\end{tikzpicture}

\end{document}



Sunrise Formula

An example using the TIKZ graph plotting package `pgfplots'.

enter image description here

\documentclass[a4paper]{article}

\usepackage{tikz}
\usepackage[margin=0.3in]{geometry}
\usepackage{pgfplots}
\pgfplotsset{width=12cm,compat=1.16}

\usetikzlibrary{math}

\newcommand\alphazero{23.44} % Earth axial tilt in degrees

% the following constants all need changing per location
\newcommand\latitude{-22.88} % latitude of location in degrees
\newcommand\avgerror{0.35} % average error between actual sunrise and computed value
\newcommand\ytop{40} % place top of graph at about 15 units higher than max y data value

\begin{document}

\begin{tikzpicture}[
    baseline,
    declare function={
        sunrise(\d,\x) = {-asin( sin(\alphazero)*cos(360*\x/365) / cos(\d) )};
    }
]

\begin{axis}[
    axis lines=left,
    xmax=400,
    ymax=\ytop,
    align=center,
    title={\textbf{ \large Actual/Computed Sunrise in} \\ \textbf{ \large Rio De Janeiro, 2018-19} },
    xlabel={\large Day Offset $(n)$ from Winter Solstice},
    ylabel={\large Degrees $(\theta)$ North of East},
    title style={outer ysep=1.3em},
    xlabel style={at={(ticklabel cs:0.5)},anchor=near ticklabel,outer ysep=1.5em},
    ylabel style={at={(ticklabel cs:0.5)},anchor=near ticklabel,outer ysep=0.9em}
]

\addplot [
    red,
    only marks,
    mark size=2.5pt
] table {rio de janeiro.dat};
\addlegendentry{Actual sunrise};

\addplot [
    blue,
    domain=0:364,
    samples=365,
    variable=n,
    line width=0.8pt
]
{sunrise(\latitude, n)} 
[xshift=-4pt,yshift=3pt] node [pos=0.25,black,anchor=east] {Spring \\ Equinox}
[xshift=6pt,yshift=5pt] node [pos=0.75,black,anchor=west] {Autumnal \\ Equinox}
[xshift=-7pt,yshift=-2pt] node [pos=0.5,black,anchor=south] {Summer Solstice}
;
\addlegendentry{Computed sunrise};

\path (axis cs:200,-20) node[draw,inner sep=3pt,anchor=south] {Average error = $\avgerror^\circ$};

\end{axis}

\end{tikzpicture}%
%
%\hspace{1em}
\begin{tikzpicture}[baseline]
\draw (0,4.5) node[draw=blue,inner sep=6pt,align=left] {\Large
$\theta = -\arcsin \left(\frac{\sin \alpha_{0} \cos \psi }{\cos \delta} \right)$ \\ \\[0.4ex]
$\delta =$ latitude $= \latitude^\circ$ \\
$\alpha_{0} =$ Earth axial tilt $= 23.44^\circ$ \\
$\psi = \frac{n}{365} (360^\circ)$
};
\end{tikzpicture}

\end{document}


Data file `rio de janeiro.dat` :-

# Rio actual sunrise
x_0 f(x)
0       -26
10      -26
20      -24
30      -22
40      -19.5
50      -16
60      -12.5
70      -8.5
80      -4
90      0
100     4
110     8
120     12
130     16
140     19
150     21
160     23
170     25
180     25
190     25
200     24
210     22
220     20
230     17
240     14
250     10
260     6
270     2
280     -2
290     -6
300     -10.5
310     -14
320     -18
330     -21
340     -23
350     -25
360     -26
365     -26


11

Here's TikZ code to draw the (special relativistic) trajectory of a uniformly accelerated observer on a spacetime diagram. The initial position, speed, and acceleration can be set in the preamble. enter image description here

%----------------------------------------------------------------------
% Use TikZ/PGF to programmatically draw spacetime diagrams for 
% uniformly accelerated observers. Set the acceleration, initial
% conditions, and other paramters below.
%----------------------------------------------------------------------
\documentclass[border=2mm]{standalone}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathrsfs}

\usepackage{tikz}
\usetikzlibrary{arrows.meta,decorations.pathmorphing,math}


%-----------------------------------------------------------------------
% Custom colors used in links and graphics
%-----------------------------------------------------------------------
\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.937, 0.161, 0.161}
\definecolor{brick}{rgb}{0.64314, 0, 0}
\definecolor{sunrise}{rgb}{0.80784, 0.36078, 0}

\newcommand{\scri}{\mathscr{I}}

\begin{document}

\pagestyle{empty} 

%-----------------------------------------------------------------------
% Set constants (speed of light, acceleration) 
%-----------------------------------------------------------------------
% The speed of light, c=1
\newcommand*{\sol}{1.0}
% The acceleration a
\newcommand*{\accel}{0.8}%

%-----------------------------------------------------------------------
% Set initial values (initial t, x, and v)
%-----------------------------------------------------------------------
% The initial time t_0
\newcommand*{\tinit}{-0.5}%
% The initial position x_0
\newcommand*{\xinit}{0.4}%
% The initial velocity. Obviously the magnitude must be less than \sol!
\newcommand*{\vinit}{-0.2}%

%-----------------------------------------------------------------------
% Set the maximum value of t
%-----------------------------------------------------------------------
\newcommand*{\tmax}{5.0}%

%-----------------------------------------------------------------------
% Set the number of time intervals
%-----------------------------------------------------------------------
\newcommand*{\numintervals}{4}

%-----------------------------------------------------------------------
% Calculate the intervals \Delta t.
%-----------------------------------------------------------------------
\pgfmathsetmacro{\tinterval}{divide(\tmax-\tinit,\numintervals+1)}

%-----------------------------------------------------------------------
% Calculate the initial proper velocity.
%-----------------------------------------------------------------------
\pgfmathsetmacro{\uinit}{divide(\vinit,sqrt(1-pow(divide(\vinit,\sol),2)))}%

%-----------------------------------------------------------------------
% Calculate the initial value of the relativistic parameter gamma.
%-----------------------------------------------------------------------
\pgfmathsetmacro{\gammainit}{divide(1,sqrt(1-divide(pow(\vinit,2),1)))}%

%-----------------------------------------------------------------------
% Now define the position x(t) of the accelerated observer. 
%-----------------------------------------------------------------------
\pgfmathdeclarefunction{pos}{1}{%
  \pgfmathparse{divide(pow(\sol,2),\accel)*(sqrt(1+pow(divide(\accel,\sol)*(#1-\tinit) + divide(\uinit,\sol),2)) - sqrt(1 + pow(divide(\uinit,\sol),2)) ) + \xinit}
}

%-----------------------------------------------------------------------
% Points on the observer's worldline are a constant proper distance 
% from the point (\xstar,\tstar).
%-----------------------------------------------------------------------
% Define \xstar
\pgfmathsetmacro{\xstar}{\xinit - divide(pow(\sol,2),\accel)*sqrt(1+pow(divide(\uinit,\sol),2))}%
% Define \tstar
\pgfmathsetmacro{\tstar}{\tinit - divide(\vinit,\accel)*\gammainit}%

%-----------------------------------------------------------------------
% Find the maximum value of x(t) so we know how big the plot should be.
%-----------------------------------------------------------------------
\pgfmathsetmacro{\xmax}{pos(\tmax)}%

%-----------------------------------------------------------------------
% Draw everything
%-----------------------------------------------------------------------
\begin{tikzpicture}[>=LaTeX]
      %-----------------------------------------------------------------------
      % Clip a rectangular region so we can draw things later without 
      % worrying about them poking out the sides of the diagram.    
      %-----------------------------------------------------------------------
      % First, set a lower value of t depending on whether \tinit is positive or negative.
      \tikzmath{
          if \tinit>0.0 then {let \tlower = -0.5*\tmax;} else {let \tlower = \tinit-0.5*\tmax;};
      }
      % Now clip the region. The +0.1 and +0.3 add padding for x and t labels and make sure the clip region doesn't end on a grid line.
      \clip (-\xmax+0.1,\tlower) -- (\xmax+0.3,\tlower) -- (\xmax+0.3,\tmax+0.3) --  (-\xmax+0.1,\tmax+0.3) -- (-\xmax+0.1,\tlower);

      %-----------------------------------------------------------------------
      % Draw a background grid.
      %-----------------------------------------------------------------------
      \draw[step=.25,blue!15] (-\xmax,-\tmax) grid (\xmax+0.3,\tmax+0.3);

      %-----------------------------------------------------------------------
      % Draw the x and t axes.
      %-----------------------------------------------------------------------
      \draw [-{Stealth[length=2.5mm]},thick] (-\xmax,0) -- (\xmax,0) node[above] {\large$x$};
      \draw [-{Stealth[length=2.5mm]},thick] (0,-\tmax) -- (0,\tmax) node[right] {\large $t$};

      %-----------------------------------------------------------------------
      % Draw lines from (\xstar,\tstar) to \numintervals evenly-spaced 
      % points on the worldline.
      %-----------------------------------------------------------------------
      \foreach \x in {0,1,...,\numintervals} {
        \draw[cornflower] (\xstar,\tstar) -- ({pos(\tinit+\x*\tinterval)},{\tinit+\x*\tinterval});
      }

      %-----------------------------------------------------------------------
      % Plot the worldline of the observer as a smooth curve with no
      % arrows on it.
      %-----------------------------------------------------------------------
      % \draw[thick, chameleon, domain=\tinit:\tmax,smooth,variable=\t,->]
      %      plot[] ({pos(\t)},{\t});

      %-----------------------------------------------------------------------
      % Plot the worldline as \numintervals equally spaced (in t)
      % segments with an arrow on each one.
      %-----------------------------------------------------------------------
      \foreach \i in {0,1,...,\numintervals} {
          \pgfmathsetmacro{\tstart}{\tinit+\i*\tinterval-0.05};
          \pgfmathsetmacro{\tfin}{\tinit+(\i+1)*\tinterval};
          \draw[thick, chameleon, domain=\tstart:\tfin,smooth,variable=\t,->]
            plot[] ({pos(\t)},{\t});
      }


      %-----------------------------------------------------------------------
      % Make a small, filled circle at (\xinit,\tinit).
      %-----------------------------------------------------------------------
      \fill[chameleon,opacity=1] (\xinit,\tinit) circle (2pt);
      % Optionally add a label next to the point.
      %\node at (\xinit+.75,\tinit) {\small $(x_0,t_0)$};

      %-----------------------------------------------------------------------
      % Draw a small, filled circle at (\xstar, \tstar).
      %-----------------------------------------------------------------------
      \fill[scarlet] (\xstar,\tstar) circle (2pt);

      %-----------------------------------------------------------------------
      %Draw the light cone of (\xstar,\tstar).
      %-----------------------------------------------------------------------
      \draw[scarlet, thick, dashed, domain=-\tmax:\tmax,smooth,variable=\t] 
        plot ({\sol*\t+\xstar},{\t+\tstar});
      \draw[scarlet, thick, dashed, domain=-\tmax:\tmax,smooth,variable=\t] 
        plot ({-\sol*\t+\xstar},{\t+\tstar});

\end{tikzpicture}   

\end{document}
10

Below I made a basic diagram to illustrate (vertical) interlinkages such as in a supply chain in an economy.

\documentclass{article}
\usepackage{tikz}
\begin{document} 
\begin{tikzpicture}
\draw (0,0) -- (6,0);
\draw (0,0) -- (0,-1); \draw (6,0) -- (6,-1);
\draw (0,0) rectangle (1,-1);
\draw (1,0) rectangle (2,-1);
\draw (2,0) rectangle (3,-1);
\draw (3,0) rectangle (4,-1);
\draw (4,0) rectangle (5,-1);
\draw (5,0) rectangle (6,-1);
\draw [yellow, line width=6] (0,-1)--(1,-1);
\draw [red, line width=6] (1,-1)--(2,-1);
\draw [green, line width=6] (2,-1)--(3,-1);
\draw [pink, line width=6] (3,-1)--(4,-1);
\draw [purple, line width=6] (4,-1)--(5,-1);
\draw [lightgray, line width=6] (5,-1)--(6,-1);
\draw[<->,thick,cyan] (0.5,-1.5) to [out=305,in=225] (1.5,-1.5); 
\draw[<->,thick,cyan] (1.5,-1.5) to [out=305,in=225] (2.5,-1.5);
\draw[<->,thick,cyan] (2.5,-1.5) to [out=305,in=225] (3.5,-1.5);
\draw[<->,thick,cyan] (3.5,-1.5) to [out=305,in=225] (4.5,-1.5);
\draw[<->,thick,cyan] (4.5,-1.5) to [out=305,in=225] (5.5,-1.5);
\node at (0.5,0.3) {I};
\node at (1.5,0.3) {II};
\node at (2.5,0.3) {III};
\node at (3.5,0.3) {IV};
\node at (4.5,0.3) {V};
\node at (5.5,0.3) {VI};
\end{tikzpicture}
\end{document} 

enter image description here

10

A couple of slides from my master degree defense... of course built with Tikz! the code contains both animations (ehm... well... overlays actually)

enter image description here enter image description here

  \documentclass{beamer}
  \usepackage{etex}
  \usepackage[utf8]{inputenc}
  \usepackage{default}
  \usepackage{tikz}
  \usetikzlibrary{calc,spy,decorations,decorations.text,decorations.pathmorphing,shapes.callouts,shapes.geometric,shapes.symbols}
  \title{Finite Volume \\ ElectroHydroDynamic Simulation \\ of Corona Discharge in Air}

  \author{Davide Cagnoni} 

  \date{20 Dicembre 2012}

  \begin{document}

  \begin{frame}[Raffreddamento tramite EHD]{Raffreddamento per Convezione Elettroidrodinamica}

  \centering

  \begin{tikzpicture}[
  velocity/.style={thick,
        blue!60!black
        },
  temperature/.style={thick,
        orange%!80!black
        }
  ]

  \clip (-2,-1) rectangle (9,4);
  % \draw [color=green,ultra thin] (-1,-1) grid[step=.25cm] (11,5);
  % \draw [ultra thin] (-2,-1) grid[step=1cm] (9,4);


  \fill[gray!70] (0,0) -- (10,0) -- ($(10,0)+{tan(5)*10}*(0,1)$) -- cycle;

  \only<2-4>
  {
  \fill[opacity=.3,velocity] (0,0) to [out=35,in=187] (10,2.8) -- ($(10,0)+{tan(5)*10}*(0,1)$) -- cycle;
  }

  \only<3-4>
  {
  \fill[opacity=.3,temperature]  (10,2.8) to [in=35,out=187]  (0,0) to [out=45,in=190] (10,3.8) -- cycle;
  }

  \only<5-6>
  {
  \fill[opacity=.3,velocity] (0,0) to [out=35,in=187] (10,1.3) -- ($(10,0)+{tan(5)*10}*(0,1)$) -- cycle;
  }
  \only<6-6>
  {
  \fill[opacity=.3,temperature]  (10,1.3) to [in=35,out=187]  (0,0) to [out=45,in=190] (10,2) -- cycle;
  }
  \only<4-6>
  {
  \node[rectangle,rotate=5,fill=green!60!black!80,text=white,align=center,font=\footnotesize,anchor=south] at ($5*(1,0)+tan(5)*5*(0,1)$) {Pompa\\ EHD};
  }

  \node[temperature,anchor=south west] at (-2.2,2.6) {$\T_{\infty}$};
  \node[velocity,anchor=south west] at (-1,2.45) {$\v_{\infty}$};

  \draw[thick,velocity] plot[domain=0:13.5] (
      { 0
      },
      { (.2*\x)
      }
    );
  \foreach \i in {1,2,...,13}
  {
      \draw[velocity,-latex] ($(-2,0) + {.2*(\i-0.5)}*(0,1)$) --
              ++ (2,0);
  }

  \draw[thick,temperature] plot[domain=0:13.5] (
      { -1.2
      },
      { (.2*\x)
      }
  );
  \foreach \i in {0,1,...,13}
  {
      \draw[temperature,-latex] ($(-2,0) +{.2*\i}*(0,1)$) --
              ++ (0.8,0);
  }

  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \only<2-6>
  {
  \node[velocity,anchor=south west,rotate=5] at ($(0.8,2.55)+(2,0) +{2*tan(5)}*(0,1)$) {$\v_{\infty}$};
  \draw[thick,velocity] plot[domain=0:13.5] (
      { 2 +  (2*(1-exp(-\x/2)))*cos(5) + (.2*\x)*(-sin(5))
      },
      { 2*tan(5) + (2*(1-exp(-\x/2)))*sin(5) + (.2*\x)*cos(5)
      }
    );
  \foreach \i in {1,2,...,13}
  {
      \draw[velocity,-latex] ($(2,0) +{2*tan(5)}*(0,1) + {-sin(5)*.2*(\i-0.5)}*(1,0) + {cos(5)*.2*(\i-0.5)}*(0,1)$) --
              ++ (${2*(1-exp(-(\i-0.5)/2))*cos(5)}*(1,0) + {2*(1-exp(-(\i-0.5)/2))*sin(5)}*(0,1)$);
  }
  }

  \only<3-6>
  {
  \node[temperature,anchor=south west,rotate=5] at ($(-0.2,2.6)+(1.8,0) +{1.8*tan(5)}*(0,1)$) {$\T_{\infty}$};
  \node[temperature,anchor=south west,rotate=5] at ($(1,-.8)+(2.5,0) +{5.8*tan(5)}*(0,1)$) {$\T_{\text{parete}}$};
  \draw[thick,temperature] plot[domain=0:13.5] (
      { 2 +  (1.3*(exp(-\x/3.5))+0.8)*cos(5) + (.2*\x)*(-sin(5))
      },
      { 2*tan(5) + (1.3*(exp(-\x/3.5))+0.8)*sin(5) + (.2*\x)*cos(5)
      }
  );
  \foreach \i in {0,1,...,13}
  {
      \draw[temperature,-latex] ($(2,0) +{2*tan(5)}*(0,1) + {-sin(5)*.2*\i}*(1,0) + {cos(5)*.2*\i}*(0,1)$) --
              ++ (${(1.3*(exp(-\i/3.5))+0.8)*cos(5)}*(1,0) + {(1.3*(exp(-\i/3.5))+0.8)*sin(5)}*(0,1)$);
  }
  }
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \only<5-6>
  {
  \node[velocity,anchor=south west,rotate=5] at ($(0.8,2.55)+(6,0) +{6*tan(5)}*(0,1)$) {$\v_{\infty}$};
  \draw[thick,velocity] plot[domain=0:13.5] (
      { 6 + (2*(1-exp(-\x/2))+ (exp(-\x/2)*2*\x) )*cos(5) 
            + (.2*\x)*(-sin(5))
      },
      { 6*tan(5) + (2*(1-exp(-\x/2))+ (exp(-\x/2)*2*\x) )*sin(5) 
              + (.2*\x)*cos(5)
      }
    );
  \foreach \i in {1,2,...,13}
  {
      \draw[velocity,-latex] ($(6,0) +{6*tan(5)}*(0,1) + {-sin(5)*.2*(\i-0.5)}*(1,0) + {cos(5)*.2*(\i-0.5)}*(0,1)$) --
              ++ (${(2*(1-exp(-(\i-0.5)/2))+ (exp(-(\i-0.5)/2)*2*(\i-0.5)) )*cos(5)}*(1,0) + 
              {(2*(1-exp(-(\i-0.5)/2))+ (exp(-(\i-0.5)/2)*2*(\i-0.5)) )*sin(5)}*(0,1)$);
  }
  }

  \only<6>
  {
  \node[temperature,anchor=south west,rotate=5] at ($(-0.2,2.6)+(5.8,0) +{5.8*tan(5)}*(0,1)$) {$\T_{\infty}$};
  \node[temperature,anchor=south west,rotate=5] at ($(1,-.5)+(5.8,0) +{5.8*tan(5)}*(0,1)$) {$\T_{\text{EHD}}$};
  \draw[thick,temperature] plot[domain=0:13.5] (
      { 6 +  (0.6*(exp(-\x/3.5))+0.8)*cos(5) + (.2*\x)*(-sin(5))
      },
      { 6*tan(5) + (0.6*(exp(-\x/3.5))+0.8)*sin(5) + (.2*\x)*cos(5)
      }
  );
  \foreach \i in {0,1,...,13}
  {
      \draw[temperature,-latex] ($(6,0) +{6*tan(5)}*(0,1) + {-sin(5)*.2*\i}*(1,0) + {cos(5)*.2*\i}*(0,1)$) --
              ++ (${(0.6*(exp(-\i/3.5))+0.8)*cos(5)}*(1,0) + {(0.6*(exp(-\i/3.5))+0.8)*sin(5)}*(0,1)$);
  }
  }

  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  \only<1>{\node[ellipse callout,
            thin,
            fill=white,draw=black,
            align=center,
            callout absolute pointer={(4,.1)}
            ]
            at (6,1.5) {Emissione di \\potenza termica};
            \node[ellipse callout,
            thin,
            fill=white,draw=black,
            align=center,
            callout absolute pointer={(-1,1.5)}
            ]
            at (2,2) {Flusso di \\aria fredda};
  }
  \only<2-3>{\node[ellipse callout,
            thin,
            fill=white,draw=black,
            align=center,
            callout absolute pointer={(5,1)}
            ]
            at (7,0) {Strato limite \\ di velocit\`a};
  }
  \only<3>{\node[ellipse callout,
            thin,
            fill=white,draw=black,
            align=center,
            callout absolute pointer={(4.5,2.5)}
            ]
            at (7,2) {Strato limite \\ di temperatura};
  }
  \only<5>{\node[ellipse callout,
            thin,
            fill=white,draw=black,
            align=center,
            callout absolute pointer={(7.2,1.5)}
            ]
            at (4,3) {Riduzione dello \\strato limite};
  }
  \only<6>{\node[ellipse callout,
            thin,
            fill=white,draw=black,
            align=center,
            callout absolute pointer={(7,.8)}
            ]
            at (4,2) {Riduzione della \\temperatura};
  }
  \end{tikzpicture}

  \end{frame}

  \begin{frame}[Effetto corona]{Ionizzazione ed Effetto Corona}

  \centering

  \begin{tikzpicture}[
  electrode/.style={top color=orange!70!black,
        bottom color=orange!40!black,
        shading angle=30
        },
  active/.style={fill opacity=0.8,
        olive!50!yellow
        },
  molecule/.style={circle,
        shade,
        shading=ball,
        ball color=red!80
  %       fill=red!80!black,
  %       draw=red!60!black,thin
        },
  ion/.style={circle,
        shade,
        shading=ball,
        ball color=green!70!black!80
  %       fill=green!70!black,
  %       draw=green!50!black,thin
        },
  electron/.style={circle,
        shade,
        shading=ball,
        ball color=blue!20!black!80
  %       fill=blue!40!black!80
        },
  x=10pt,y=10pt,baseline,decoration=snake
  ]

 \only<2-9>
  {
  \clip (-11.1,-12) rectangle (23,3.1);
  % \draw [color=green,ultra thin] (-13,-11) grid[step=.25] (13,3);
  % \draw [ultra thin] (-13,-11) grid[step=1] (13,3);
  \node[anchor=west,matrix,draw=black,ampersand replacement=\&,thin,column sep=1.5,row sep=1] (my matrix) at (11,-4.5)
  {
  \path[molecule] (.5,0) circle (2pt);  \& \node at (0,0) {Molecola neutra}; \\
  \path[ion] (.5,0) circle (2pt);   \& \node at (0,0) {Ione positivo}; \\
  \path[electron] (.5,0) circle (1pt);  \& \node at (0,0) {Elettrone}; \\
  \node[starburst,fill=cyan,fill opacity=0.3,random starburst,transform canvas={scale=.8,xshift=-.5}] at (0,0) {};  \& \node at (0,0) {Urto elastico}; \\
  \node[starburst,fill=yellow,fill opacity=0.7,random starburst,transform canvas={scale=.8,xshift=-.5}] at (0,0) {};    \& \node at (0,0) {Urto anelastico}; \\
  \fill[active] (0,-.5) rectangle (1,.5) ;  \& \node at (0,0) {Zona attiva}; \\
  \shade[electrode] (0,-.5) rectangle (1,.5) ;  \& \node at (0,0) {Elettrodi}; \\
  \draw[thin,black!70] (0,.5) to[out=-20,in=100] (1,-.5) ;  \& \node at (0,0) {Linee di campo}; \\
  };

  \foreach \angle in {0,30,...,240}
  {
  \draw[thin,black!70] plot[smooth,domain=0:100] (
      { (cos(-210+\angle))      *(1-pow(\x/100,3))
          +1.5*(\angle/24-5)        *pow(\x/100,3)
      },
      { (sin(-210+\angle))      *(1-pow(\x/100,7))
              +(-11)            *pow(\x/100,7)
      }
    );
  }

  \fill[active] (0,-1) circle (2.1);
  \shade[electrode] (0,0) circle (1);
  \shade[electrode] (-10,-12) rectangle (10,-11);
  % \only<1-9>
  % {
  \foreach \i in {0,1,...,10}
  {
  \path[electron] (${rand*10}*(1,0)+{7*rand-4}*(0,1)$) circle (1pt);
  }

  \foreach \i in {0,1,...,150}
  {
  \path[molecule] (${rand*10}*(1,0)+{7*rand-4}*(0,1)$) circle (2pt);
  }
  % }
  \only<2>
      {
      \path[electron] (4,-9) circle (1pt);
      \path[electron] (3,-11) circle (1pt);
      \draw[latex-,ultra thick,color=yellow,decorate,decoration={coil,aspect=0,pre length=10pt,post length=0pt}]  (3,-11) -- ++(-5,2);
      \node[ellipse callout,
            thin,
            fill=white,draw=black,
            %text width=2cm,
            align=center,
            anchor=225,
            callout absolute pointer={($(4,-9)+(-2pt,2pt)$)}
            ]
            at (-2,-7.5) {Elettrone libero};
      }
  \only<3>
      {
      \node[starburst,fill=cyan,fill opacity=0.3,random starburst] at ($(1.6,-4.5)+(-1pt,+1pt)$) {};
      \path[electron] (1.6,-4.5) circle (1pt);
      \path[molecule] ($(1.6,-4.5)+(2pt,+2pt)$) circle (2pt);
      \node[ellipse callout,
            thin,
            fill=white,draw=black,
            %text width=2cm,
            anchor=225,
            callout absolute pointer={($(1.6,-4.5)+(2pt,-2pt)$)}
            ]
            at (3.4,-7) {Urti elastici};%{Collisioni \\elastiche};
      }
  \only<4>
      {
      \node[starburst,fill=yellow,fill opacity=0.6,random starburst] at ($(1.8,-2)+(-2pt,+2pt)$) {};
      \path[electron] (1.8,-2) circle (1pt);
      \path[molecule] ($(1.8,-2)+(-3pt,+3pt)$) circle (2pt);
      \node[ellipse callout,
            thin,
            fill=white,draw=black,
            align=center,
            %text width=4cm,
            anchor=45,
            callout absolute pointer={($(1.8,-2)+(-2pt,-2pt)$)}
            ]
            at (0,-3) {Urto \\anelastico};
      }
  \only<5>
      {
      \node[starburst,fill=yellow,fill opacity=0.6,random starburst] at ($(1.8,-2)+(-2pt,+2pt)$) {};
      \path[electron] ($(1.8,-2)+(-4pt,+3pt)$) circle (1pt);
      \path[electron] ($(1.8,-2)+(0pt,+4pt)$) circle (1pt);
      \path[ion] ($(1.8,-2)+(-1pt,+1pt)$) circle (2pt);
      \node[ellipse callout,
            thin,
            fill=white,draw=black,
            align=center,
            %text width=4cm,
            anchor=45,
            callout absolute pointer={($(1.8,-2)+(-2pt,-2pt)$)}
            ]
            at (0,-3) {Ionizzazione};
      }
  \only<6>
      {
      \node[starburst,fill=yellow,fill opacity=0.6,random starburst] at ($(1.2,-2)+(-2pt,+2pt)$) {};
      \node[starburst,fill=yellow,fill opacity=0.6,random starburst] at ($(1.8,-1.5)+(-2pt,+2pt)$) {};

      \path[electron] ($(1.2,-2)+(0pt,+0pt)$) circle (1pt);
      \path[molecule] ($(1.2,-2)+(-3pt,+3pt)$) circle (2pt);

      \path[electron] ($(1.8,-1.5)+(0pt,+0pt)$) circle (1pt);
      \path[molecule] ($(1.8,-1.5)+(-3pt,+3pt)$) circle (2pt);

      \node[ellipse callout,
            thin,
            fill=white,draw=black,
            align=center,
            %text width=4cm,
            anchor=135,
            callout absolute pointer={($(1.5,-1.7)+(2pt,-2pt)$)}
            ]
            at (4,0) {Nuovi \\ urti};

      \path[ion] (1.6,-3.2) circle (2pt);
      \node[ellipse callout,
            thin,
            fill=white,draw=black,
            align=center,
            %text width=4cm,
            anchor=35,
            callout absolute pointer={($(1.6,-3.2)+(-4pt,-2pt)$)}
            ]
            at (2,-6) {Deriva};%{Corrente \\ionica};

      }
  \only<7>
      {
      \node[starburst,fill=yellow,fill opacity=0.6,random starburst] at ($(1.2,-2)+(-2pt,+2pt)$) {};
      \node[starburst,fill=yellow,fill opacity=0.6,random starburst] at ($(1.8,-1.5)+(-2pt,+2pt)$) {};

      \path[electron] ($(1.2,-2)+(-4pt,+3pt)$) circle (1pt);
      \path[electron] ($(1.2,-2)+(0pt,+4pt)$) circle (1pt);
      \path[ion] ($(1.2,-2)+(-1pt,+1pt)$) circle (2pt);

      \path[electron] ($(1.8,-1.5)+(-4pt,+3pt)$) circle (1pt);
      \path[electron] ($(1.8,-1.5)+(0pt,+4pt)$) circle (1pt);
      \path[ion] ($(1.8,-1.5)+(-1pt,+1pt)$) circle (2pt);

      \node[ellipse callout,
            thin,
            fill=white,draw=black,
            align=center,
            %text width=4cm,
            anchor=135,
            callout absolute pointer={($(1.5,-1.7)+(2pt,-2pt)$)}
            ]
            at (6,-1) {Valanga};

      \path[ion] (2.1,-4) circle (2pt);
      }
  \only<8>
      { 
      \foreach \l in {1,2,...,5}
          {
          \path[molecule] ($(0,-1)+({rand*100-90}:{rnd*2.1})$) circle (2pt);
          \path[ion] ($(0,-1)+({rand*120-90}:{rnd*2.1})$) circle (2pt);
          \path[ion] ($(0,-1)+({rand*120-90}:{rnd*2.1})$) circle (2pt);
          \path[electron] ($(0,-1)+({rand*100-90}:{rnd*2.1})$) circle (1pt);
          \path[electron] ($(0,-1)+({rand*100-90}:{rnd*2.1})$) circle (1pt);
          }

      \node[starburst,fill=cyan,fill opacity=0.3,random starburst] at ($(2.1,-4)$) {};
      \node[starburst,fill=cyan,fill opacity=0.3,random starburst] at ($(1.7,-5)$) {};
      \node[starburst,fill=cyan,fill opacity=0.3,random starburst] at ($(2.4,-4.7)$) {};

      \path[ion] ($(2.1,-4)+.7*(2pt,2pt)$) circle (2pt);
      \path[molecule] ($(2.1,-4)+.7*(-2pt,-2pt)$) circle (2pt);

      \path[ion] ($(1.7,-5)+.7*(0pt,3pt)$) circle (2pt);
      \path[molecule] ($(1.7,-5)+.7*(-1pt,-2pt)$) circle (2pt);

      \path[ion] ($(2.4,-4.7)+.7*(-2pt,2pt)$) circle (2pt);
      \path[molecule] ($(2.4,-4.7)+.7*(2pt,-2pt)$) circle (2pt);

      \node[ellipse callout,
            thin,
            fill=white,draw=black,
            align=center,
            %text width=4cm,
            anchor=45,
            callout absolute pointer={($(1.8,-4.4)$)}
            ]
            at (-1,-3) {Urti \\elastici};


      }
  \only<9>
      {
      \foreach \l in {1,2,...,5}
            {
            \path[molecule] ($(0,-1)+({rand*100-90}:{rnd*2.1})$) circle (2pt);
            \path[ion] ($(0,-1)+({rand*120-90}:{rnd*2.1})$) circle (2pt);
            \path[ion] ($(0,-1)+({rand*120-90}:{rnd*2.1})$) circle (2pt);
            \path[electron] ($(0,-1)+({rand*100-90}:{rnd*2.1})$) circle (1pt);
            \path[electron] ($(0,-1)+({rand*100-90}:{rnd*2.1})$) circle (1pt);
            }
      \foreach \l in {1,2,...,10}
            {
            \foreach \i in {0,1,2}
                {
                \path[ion] (${(sqrt(\l)*2+1)*rand}*(1,0)+{rnd-\l-1}*(0,1)$) circle (2pt);
                }
            %\pgfmathsetseed{\l}
            \coordinate (mycenterpoint) at (${(sqrt(\l)*2+1)*rand}*(1,0)+{rnd-\l-1}*(0,1)$);
            \coordinate (myangle) at ($(rand*180:1.4pt)$);
            \node[starburst,random starburst,fill=cyan,fill opacity=0.3,random starburst] at (mycenterpoint) {};
            \path[ion] (mycenterpoint) ++(myangle) circle (2pt);
            \path[molecule] (mycenterpoint) ++($-1*(myangle)$) circle (2pt);
            }
      \node[ellipse callout,
            thin,
            fill=white,draw=black,
            align=center,
            %text width=4cm,
            anchor=east,
            callout absolute pointer={($(-1,-5)$)}
            ]
            at (-3,-4) {Forza di \\Coulomb};
      }
  }
  \end{tikzpicture}
  \end{frame}

  \end{document}
  • just to point it out: no rastered graphics in here! – Davide Dec 6 '15 at 18:33
10

Here is a picture i created during my time as a student working for the departure of semiconductors at my university. The picture shows a bandmodel of a semiconductor under optical generation. The light comes in on the left with the energy h*nu. At the surface of the semiconductor we get more charge carriers (holes and electrons) which decrease into the bulk of the semiconductor. Furthermore, we can see that this is a p-type semiconductor, since in the bulk we have more holes than electrons. Also we can see the non-mobile charge carriers of the aceptors (now negatively charged). On the right of the picture we see the same bandmodel, but now we consider the energies. Due to the generation of carriers at the surface, the quasi-fermi-levels for electrons and holes start to part from the actual fermi level in the bulk of the semiconductor. Here again we can see the p-type of the semiconductor since the fermi level is below the intrinsic fermi level.

The data for the quasi-fermi-levels was calculated, but i don't have the original calculation anymore. Thats why I just "faked" it using exponentiell functions. This gets very close to the original.

Bandmodel

The Code for the picture (compile with lualatex)

\documentclass{scrartcl}

\usepackage{fontspec}

% language
\usepackage{polyglossia}
\setmainlanguage{german}

\usepackage{tikz}
\usetikzlibrary{decorations, decorations.pathmorphing, decorations.pathreplacing, positioning, arrows, calc}
\tikzset{
    linewidth/.style={semithick},
    line/.style={-, linewidth}, % line style to use for all lines
    tip/.style={->, >=stealth', linewidth}, % tip (arrow)
    rtip/.style={<-, >=stealth', linewidth}, % reverse tip
    bitip/.style={<->, line, >=stealth', linewidth}, % tip in both directions
    every pin edge/.style={rtip}, % style for all pins
    % styles
    mobile/.style={draw, circle, inner sep=0pt, minimum size=0.35cm, font=\scriptsize, linewidth},
    fixed/.style={draw, fill=white, rectangle, inner sep=0pt, minimum size=0.37cm, font=\scriptsize, linewidth}
}
\pagestyle{empty}

\begin{document}
\def\bandmodelwidth{5cm}
\def\bandmodelwidthdiml{2.5}
\def\bandmodelheight{3cm}
\def\bandmodelfermi{0.3}
\begin{tikzpicture}
    \draw[thick] (-\bandmodelwidth/2, 0) -- (\bandmodelwidth/2, 0) node[right] { $W_V$ };
    \draw[thick] (-\bandmodelwidth/2, \bandmodelheight) -- (\bandmodelwidth/2, \bandmodelheight) node[right] { $W_C$ };
    \draw[dashed,thick] (-\bandmodelwidth/2, \bandmodelfermi * \bandmodelheight) -- (\bandmodelwidth/2, \bandmodelfermi * \bandmodelheight) node[right] { $W_F$ };
    \coordinate (valence east)    at ( \bandmodelwidth/2, 0);
    \coordinate (valence west)    at (-\bandmodelwidth/2, 0);
    \coordinate (conduction east) at ( \bandmodelwidth/2, \bandmodelheight);
    \coordinate (conduction west) at (-\bandmodelwidth/2, \bandmodelheight);
    \coordinate (fermi east)      at ( \bandmodelwidth/2, \bandmodelfermi * \bandmodelheight);
    \coordinate (fermi west)      at (-\bandmodelwidth/2, \bandmodelfermi * \bandmodelheight);
    \coordinate (intrinsic east)  at ( \bandmodelwidth/2, 0.5 * \bandmodelheight);
    \coordinate (intrinsic west)  at (-\bandmodelwidth/2, 0.5 * \bandmodelheight);
    \draw[tip] let \n1={1.5} in ($(valence west)-(\n1, 0)$) -- ($(conduction west)-(\n1, 0)$) node[above] {$W$ };
    \draw[tip] ($(valence west)-(2, 0.5)$) -- +(1, 0) node[right] { $x$ };
    % generation arrows
    \draw[tip] ($(valence west) + (0.3, 0)$) -- ($(conduction west) + (0.3, 0)$);
    \draw[tip] ($(valence west) + (0.6, 0)$) -- ($(conduction west) + (0.6, 0)$);
    \draw[tip] ($(valence west) + (0.9, 0)$) -- node[right] { $G_{o}$ } ($(conduction west) + (0.9, 0)$);
    % mobile carriers
    \foreach \x in { 2.4, 3.0, 3.6, 4.2, 4.8 }
    {
        \node[mobile] at ($(valence west) + (\x, -0.25)$) { + };
    }
    \foreach \x in { 0.2, 0.6, 1.0, 1.4 }
    {
        \node[mobile, text height=1ex] at ($(conduction west) + (\x, 0.25)$) { - };
        \node[mobile] at ($(valence west) + (\x, -0.25)$) { + };
    }
    \node[mobile, text height=1ex] at ($(conduction west) + (3.2, 0.25)$) { - };
    \node[mobile, text height=1ex] at ($(conduction west) + (4.0, 0.25)$) { - };
    \foreach \x in { 0.2, 0.6, 1.0 }
    {
        \node[mobile, text height=1ex] at ($(conduction west) + (\x, 0.65)$) { - };
        \node[mobile] at ($(valence west) + (\x, -0.65)$) { + };
    }
    \foreach \x in { 0.2, 0.6 }
    {
        \node[mobile, text height=1ex] at ($(conduction west) + (\x, 1.05)$) { - };
        \node[mobile] at ($(valence west) + (\x, -1.05)$) { + };
    }
    \foreach \x in { 0.2 }
    {
        \node[mobile, text height=1ex] at ($(conduction west) + (\x, 1.45)$) { - };
        \node[mobile] at ($(valence west) + (\x, -1.45)$) { + };
    }
    % non-mobile charge carriers
    \foreach \x in { 1.0, 2.2, 3.4, 4.6 }
    {
        \node[fixed, text height=1ex] at ($(fermi west) + (\x, 0)$) { - };
    }
    % radiation
    \draw[tip] decorate [decoration={snake, post length=3pt, amplitude=2pt}] { ($(intrinsic west) + (-1, 0.5)$) -- node[above] { $h \nu$ }($(intrinsic west) + (0, 0.5)$) };
    \draw[tip] decorate [decoration={snake, post length=3pt, amplitude=2pt}] { ($(intrinsic west) + (-1, 0)$) -- ($(intrinsic west) + (0, 0)$) };
    \draw[tip] decorate [decoration={snake, post length=3pt, amplitude=2pt}] { ($(intrinsic west) + (-1, -0.51)$) -- ($(intrinsic west) + (0, -0.5)$) };
    % current vectors
    \draw[tip] ($(conduction west) + (1, 1.8)$) -- node[above] { $\vec{j_n}$ } ($(conduction west) + (0.2, 1.8)$);
    \draw[tip] ($(valence west) + (0.2, -1.8)$) -- node[below] { $\vec{j_p}$ } ($(valence west) + (1, -1.8)$);
    %
    \draw[decorate, decoration={brace, mirror}] ($(valence west) + (2.2, -0.5)$) -- node[below] { $p_{p_0}$} ($(valence west) + (5.0, -0.5)$);
    \draw[decorate, decoration={brace}] ($(conduction west) + (3.0, 0.5)$) -- node[above] { $n_{p_0}$} ($(conduction west) + (4.2, 0.5)$);
    % now draw the second bandmodel shifted to the right
    \begin{scope}[xshift=6.5cm]
        \draw[thick] (-\bandmodelwidth/2, 0) -- (\bandmodelwidth/2, 0) node[right] { $W_V$ };
        \draw[thick] (-\bandmodelwidth/2, \bandmodelheight) -- (\bandmodelwidth/2, \bandmodelheight) node[right] { $W_C$ };
        \draw (-\bandmodelwidth/2, 0.5*\bandmodelheight) -- (\bandmodelwidth/2, 0.5*\bandmodelheight) node[right] { $W_i$ };
        \draw[dashed,thick] (-\bandmodelwidth/2, \bandmodelfermi * \bandmodelheight) -- (\bandmodelwidth/2, \bandmodelfermi * \bandmodelheight) node[right] { $W_F$ };
        \begin{scope}[yshift=\bandmodelfermi*\bandmodelheight]
            %\draw[semithick] plot file {bandtable_wfn.dat};
            %\draw[semithick] plot file {bandtable_wfp.dat};
            \draw[semithick] plot[samples=200, domain=-\bandmodelwidthdiml:\bandmodelwidthdiml] function{1.5 * 1/(1 + exp(5*(x +1)))};
            \draw[semithick] plot[samples=200, domain=-\bandmodelwidthdiml:\bandmodelwidthdiml] function{-0.5*1/(1 + exp(5*(x +1)))};
            \node[pin=20:{$W_{F_n}$}] at (-1.2, 1) { };
            \node[pin=-15:{$W_{F_p}$}] at (-1.0, -0.15) { };
        \end{scope}
    \end{scope}
\end{tikzpicture}
\end{document}
  • great work, very nice :) – Thomas Mar 17 '16 at 15:11
  • 1
    The upper negative charges should have the correct minus signs in them, not hyphens. This ruins the picture in my view. – lblb May 22 '17 at 15:32
7

Here is our TikZpicture for the Poincare's disk model. We pay attention to that from the announcement of the Fields Medal 2018 - Akshay Venkatesh https://plus.maths.org/content/AV.

% TikZ codes by Le Huy Tien and Bui Quy
% For other TikZ/PGF, Asymptote code, see
% http://tikz.vn/vi/hinhve/mo-hinh-dia-poincare/
\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{calc}
\newcommand{\geodesicarc}[4]
{
\def\R{#1} % radius of the big circle
\def\qone{#2} % start angle of the geodesic arc
\def\qtwo{#3} % end angle of the geodesic arc
\def\geodesiccolor{#4} % color of the geodesic arc

\pgfmathsetmacro{\f}{(\qtwo-\qone)/2}
\pgfmathsetmacro{\dq}{abs(\f)}
\pgfmathsetmacro{\r}{\R*tan(\dq)} % radius of the geodesic arc
\pgfmathsetmacro{\rp}{sqrt(\r*\r+\R*\R)} % distance of 2 centers 

\coordinate (I) at (\f+\qone:\rp);
\fill [color=\geodesiccolor] (I) circle (\r);
}% end of \geodesicarc command
\begin{document}
\begin{tikzpicture}
\def\RR{3} % radius of the Poincare's disk
\colorlet{Pdiskcolor}{violet} % color of the Poincare's disk

\clip (0:0) circle (\RR);
\fill[Pdiskcolor] (0,0) circle (\RR);

% Initiate geodesic triangle
\foreach \i in {-30,90,210}
\geodesicarc{\RR}{\i}{\i+120}{white};

% 1st iteration
\foreach \i in {-30,30,...,330}
\geodesicarc{\RR}{\i}{\i+60}{Pdiskcolor};

% 2nd iteration
\foreach \i in {-30,0,...,330}
\geodesicarc{\RR}{\i}{\i+30}{white};

% 3rd iteration
\foreach \i in {-30,-15,...,345}
\geodesicarc{\RR}{\i}{\i+15}{Pdiskcolor};

% 4th iteration
\foreach \i in {-30,-22.5,...,352.5}
\geodesicarc{\RR}{\i}{\i+7.5}{white};

% 5th iteration
\foreach \i in {-30,-26.25,...,356.25}
\geodesicarc{\RR}{\i}{\i+3.75}{Pdiskcolor};

% 6th iteration
\foreach \i in {-30,-28.125,...,358.125}
\geodesicarc{\RR}{\i}{\i+1.875}{white};

\draw[gray] (0,0) circle(\RR);
\end{tikzpicture} 
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.