Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
11  
that's easy :p dx.doi.org/10.1007/978-3-642-36763-2_46 –  percusse Feb 5 at 8:43
11  
I'll be glad if Till Tantau himself decide to participate, but that would be a bit unfair ... :) –  Thomas Feb 5 at 8:47
3  
What a wonderful question and answers, this is a true feeding frenzy for my inner geek :) –  Kuba Ober Feb 6 at 15:28
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 at 0:06
6  
@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 at 0:22
show 23 more comments

47 Answers 47

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}
share|improve this answer
1  
The beamer presentation that you linked is awesome –  Thomas Feb 6 at 16:02
show 2 more comments

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Prime factorization

\documentclass{article}

\usepackage{pst-tree}
\usepackage{xintexpr}
\usepackage{siunitx}

\psset{
  levelsep=1,
  treesep=1,
  nodesep=2pt
}

\catcode`\_ 11

% This code (non-expandable) produces {{}{}{N}} followed by
% successive braced triplets {{p}{k}{m}} where p is
% a prime factor of N,  k its exponent in N, and m is
% the result of dividing N by p^k and all previous
% powers of smaller primes. So, the last triplet has m = 1.

% The code uses package xint to be able to deal
% with numbers larger than the TeX limit of 2^{31}-1
% on count registers. 

\def\factorize#1{%
    \edef\factorize_N{#1}%
    \def\factorize_exp{0}%
    \edef\factors{{{}{}{\factorize_N}}}%
    \factorize_i
}

\def\factorize_i{%
    \if\xintOdd{\factorize_N}1%
       \expandafter \factorize_ii
    \else
       \edef\factorize_exp{\xintInc{\factorize_exp}}%
       \edef\factorize_N{\xintHalf{\factorize_N}}%
       \expandafter \factorize_i
    \fi
}

\def\factorize_ii{%
    \if\xintSgn{\factorize_exp}1% 
          \edef\factors{\factors{{2}{\factorize_exp}{\factorize_N}}}%
    \fi
    \if\expandafter\XINT_isOne\expandafter{\factorize_N}1%
    \else
       \def\factorize_M{3}%
       \def\factorize_exp{0}%
       \expandafter \factorize_iii
    \fi
}

\def\factorize_iii{%
    \xintAssign\xintDivision\factorize_N\factorize_M\to
        \factorize_Q\factorize_R
    \xintSgnFork{\xintSgn\factorize_R}%
        {}%
        {\edef\factorize_exp{\xintInc{\factorize_exp}}%
         \let\factorize_N\factorize_Q 
         \factorize_iii}%
        {\factorize_iv}% 
}

 \def\factorize_iv{%
    \if\xintSgn{\factorize_exp}1%
       \edef\factors{\factors{{\factorize_M}{\factorize_exp}{\factorize_N}}}%
    \fi
    \if\expandafter\XINT_isOne\expandafter{\factorize_N}1%
    \else
       % Here N > 1, N = QM+R (0 < R < M) is < M(Q+1) and N has no
       % prime factors at most equal to M. If a prime P > M divides N, the
       % quotient N/P will be < Q+1, hence at most Q. If Q <= M, then
       % N/P must be 1 else there would be some prime <=M dividing N.
       \if\xintGeq\factorize_M\factorize_Q 1% Implies that N is prime.
          \edef\factors{\factors{{\factorize_N}{1}{1}}}% We stop here.
       \else% We go on testing with bigger factors.
          % \edef\factorize_M{\xintInc{\xintInc{\factorize_M}}}%
          \edef\factorize_M{\xintiAdd \factorize_M 2}%
          \def\factorize_exp{0}%
          \expandafter \expandafter \expandafter \factorize_iii
       \fi
    \fi
}

\catcode`\_ 8

% We now define the macro \FactorTree which will produce
% a tree displaying the factorization.

\newtoks\FactorTreeA
\newtoks\FactorTreeB

\makeatletter

\newcommand*\FactorsToTree[1]{%
    \FactorsToTree@ #1%
}

% Macro which was used to produce the images;
% variant follows which skips the exponents equal to 1.

% \newcommand*\FactorsToTree@[3]{%
%     \xintSgnFork{\xintCmp{#3}{1}}% check to see if end has been reached
%     {}%
%     {\FactorTreeA\expandafter{\the\FactorTreeA
%                               \Tcircle{$\num{#1}^{#2}$}%
%                               \TR{1}%
%                               }}%
%     {\FactorTreeA\expandafter{\the\FactorTreeA 
%                              \Tcircle{$\num{#1}^{#2}$}%
%                              \psTree{\TR{\num{#3}}}}%
%      \FactorTreeB\expandafter{\the\FactorTreeB \endpsTree}}%
% }


% This variant will not print the exponents equal to 1:

\newcommand*\FactorsToTree@[3]{%
    \ifnum 0#2=1 % First triplet has an empty #2, hence the trick with 0.
       \expandafter\@firstoftwo
    \else
       \expandafter\@secondoftwo
    \fi
    % Exponent #2 is 1, so don't print it.
    {\xintSgnFork{\xintCmp{#3}{1}}% Check to see if end has been reached.
    {}%
    {\FactorTreeA\expandafter{\the\FactorTreeA
                              \Tcircle{$\num{#1}$}%
                              \TR{1}%
                              }}%
    {\FactorTreeA\expandafter{\the\FactorTreeA 
                             \Tcircle{$\num{#1}$}%
                             \psTree{\TR{\num{#3}}}}%
     \FactorTreeB\expandafter{\the\FactorTreeB \endpsTree}}}
    % Exponent #2 is > 1 (or absent in the {}{}{N} triplet).
    {\xintSgnFork{\xintCmp{#3}{1}}% Check to see if end has been reached.
    {}%
    {\FactorTreeA\expandafter{\the\FactorTreeA
                              \Tcircle{$\num{#1}^{#2}$}%
                              \TR{1}%
                              }}%
    {\FactorTreeA\expandafter{\the\FactorTreeA 
                             \Tcircle{$\num{#1}^{#2}$}%
                             \psTree{\TR{\num{#3}}}}%
     \FactorTreeB\expandafter{\the\FactorTreeB \endpsTree}}}%
}

\makeatletter
\def\@factorinliner #1{\@factorinliner@#1}
\def\@factorinliner@#1#2#3{%
  \ifnum #2>1 \expandafter\@firstoftwo\else
              \expandafter\@secondoftwo\fi%
  {{#1}^{#2}}{\num{#1}}%
}
\newcommand*\FactorizeInline[1]{%
  \factorize{#1}% 
  \xintListWithSep\cdot
    {\xintApply\@factorinliner{\expandafter\@gobble\factors}}%
}%

\newcommand*\FactorTree[1]{%
    \factorize{#1}%
    \FactorTreeA{\@gobbletwo}%
    \FactorTreeB{}%
    \xintApplyUnbraced\FactorsToTree{\factors}%
    \the\FactorTreeA\the\FactorTreeB
    \vspace{12ex}
    $\num{#1} = \FactorizeInline{#1}$
}

\makeatother

\pagestyle{empty}

\begin{document}

\FactorTree{1689242184972}

\end{document}

output

share|improve this answer
add comment

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

share|improve this answer
show 4 more comments

Edit: Oops, realized too late this was about images drawn using latex.

Typing up a conference paper for ICGG 2014 in Innsbruck about phase spaces and fitness landscapes. Although I'm a programmer for a 3D CAD company, I've grown very tired of rendered images as of late. I find it very difficult to draw focus to specific salient details in a digital image.

Although I heavily rely on 3D software and custom programming to generate the geometry in these images, everything is ultimately hand-drawn. Labels are added directly in LaTeX using \put commands, so the images are kept clean.

enter image description here

enter image description here

enter image description here

enter image description here

Not sure what anyone is going to learn from the code, but here is the tex for the bottommost image:

\begin{figure}[H] \centering
\begin{overpic}[width=.95\linewidth]{Images/OverconstrainedLandscape}
 \put (40,15) {\smaller[2] $\nicecirc{1}$}
 \put (66,35) {\smaller[2] $\nicecirc{1}$}
 \put (3,46)  {\smaller[2] $\nicecirc{2}$}
 \put (45,55) {$\pazocal{L}^\prime$}
\end{overpic}
\caption{Geometry of overconstrainedness}
\label{fig:overconstrainedlandscape}
\end{figure}
share|improve this answer
2  
This does not really answer the question, because the question is interested in graphics that were actually created in LaTeX, and not included from image files. Also please post an image of the result of the included code. –  marczellm Feb 11 at 21:49
1  
Very nice pictures. It would be great if we could draw such pictures in LaTeX:-) –  Marc van Dongen Feb 14 at 12:26
show 4 more comments

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}
share|improve this answer
2  
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). –  Yori Feb 18 at 8:48
add comment

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}
share|improve this answer
show 1 more comment

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}
share|improve this answer
add comment

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}
share|improve this answer
add comment

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);
share|improve this answer
add comment

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}%
share|improve this answer
show 1 more comment

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

share|improve this answer
3  
I really like both images, but the cool thing would be to make them in LaTeX (and Friends). –  Manuel Feb 7 at 12:26
8  
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 at 12:45
show 3 more comments

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

share|improve this answer
add comment

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

share|improve this answer
add comment

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{xfrac}
\usepackage{totcount}

%%% Constants %%%

\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff

\def\HalveringerA{\calc{\Halveringer-1}}
\def\HalveringerB{\calc{\Halveringer+1}}
\def\konstA{\calc{10*2^(-\iA)}}
\def\konstI{\num{\calc{10*\konstA}}}
\def\konstB{\calc{2^(-\Halveringer)}}
\def\konstC{\calc{16*2^(-\iA)}}
\def\konstD{\calc{16-\konstC}}
\def\konstE{\calc{2*\Halveringer+0.25}}
\def\konstF{\calc{\konstE+0.25}}
\def\konstG{\calc{\konstE-0.25}}
\def\konstH{\calc{\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{xfrac}
\usepackage{totcount}

%%% Constants %%%

\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff

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

\def\halveringerB{\calc{\Halveringer-1}}
\def\halveringerC{\calc{\Halveringer+1}}
\def\konstA{\calc{1.5*\i+0.25}\space}
\def\konstB{\calc{32*2^(-\i)}}
\def\konstC{\calc{32-\konstB}}
\def\konstD{\calc{1.5*\halveringerC+0.75}}
\def\konstE{\calc{\konstD-0.75}}
\def\konstF{\calc{\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 none the less.

share|improve this answer
show 2 more comments

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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