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.

Is it possible to make a plot like this with TikZ or other drawing packages?

Coordinate transformation from (T,X) to (t,x)

This plot visualizes a two parameter family of curves, given by

T = x Sinh(t)
X = x Cosh(t)

The pink curves are curves of constant t and curves of constant x. The plot is from http://en.wikipedia.org/wiki/Rindler_space

share|improve this question

2 Answers 2

up vote 12 down vote accepted

Yes, that kind of plot is totally within TikZ's remit. See below.

Remark: the curves of constant t on the picture you posted seem to be incorrectly labelled, e.g. "t=1" instead of "t=0.5", "t=2 instead of "t=1", etc.

enter image description here

\documentclass[10pt]{article}  
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usepackage{xcolor}

\definecolor{gridcolor}{RGB}{255 216 234} 
\definecolor{gridlabelcolor}{RGB}{255 24 131} 

\def\rnd#1{
    \pgfmathprintnumberto[precision=2]{#1}{\temp}\temp
}

\begin{document}
\begin{tikzpicture}[%
    scale=3,%
    maingrid/.style={draw=gridcolor,very thick},%
    subgrid/.style={draw=gridcolor,thin},%
    tlabels/.style={pos=0.88,above,sloped,yshift=-.3ex,gridlabelcolor},%
    label/.style={%
        postaction={%
            decorate,%
            transform shape,%
            decoration={%
                markings,%
                mark=at position .65 with \node #1;%
            }%
        }%
    },%
]%
    \pgfmathdeclarefunction{arcosh}{1}{\pgfmathparse{ln(#1+sqrt(#1+1)*sqrt(#1-1))}}
    \pgfmathsetmacro{\Xmax}{1.2}
    \pgfmathsetmacro{\Tmax}{1.2}
    \pgfmathsetmacro{\g}{1}
    \newcommand\mylabelstyle\tiny

    % curves t=constant
    \foreach \t in {-3,-2.9375,...,3}{%
        \path[subgrid] (0,0) -- (\Xmax,{\Xmax*tanh(\g*\t)});
    }
    \foreach \t in {-3,-2.75,...,3}{%
        \path[maingrid] (0,0) -- (\Xmax,{\Xmax*tanh(\g*\t)});
    }   

    % curves x=constant
    \foreach \xx in {0.05,0.1,...,\Xmax}{%
        \path[subgrid]
            plot[domain=-{arcosh(\Xmax/\xx)/\g}:{arcosh(\Xmax/\xx)/\g}]
            ({\xx*cosh(\g*\x)},{\xx*sinh(\g*\x)});  
    }
    \foreach \xx in {0.2,0.4,...,1}{%
        \path[maingrid]
            plot[domain=-{arcosh(\Xmax/\xx)/\g}:{arcosh(\Xmax/\xx)/\g}]
            ({\xx*cosh(\g*\x)},{\xx*sinh(\g*\x)});  
    }

    % curve labels
    \foreach \t in {-1,-.5,...,1}{%
        \path (0,0) -- (\Xmax,{\Xmax*tanh(\g*\t)})
            node[tlabels] {\mylabelstyle$t=\t$};
    }
    \foreach \xx in {0.4,0.6,...,1.01}{%
        \path[gridlabelcolor,label={[above]{\mylabelstyle $x=\rnd{\xx}$}}]
            plot[domain=-{arcosh(\Xmax/\xx)/\g}:{arcosh(\Xmax/\xx)/\g}]
            ({\xx*cosh(\g*\x)},{\xx*sinh(\g*\x)});  
    }

    % X-axis, T-axis, and dashed lines t=+/-infty 
    \draw[thick,-stealth] (0,0) -- (\Xmax,0) node[below] {$X$};
    \draw[thick,-stealth] (0,0) -- (0,\Tmax) node[left] {$T$};
    \draw[dashed] (0,0) -- (\Xmax,\Tmax) 
        node[pos=0.37,above,sloped,yshift=-.3ex] {\mylabelstyle$x=0$}
        node[tlabels,black] {\mylabelstyle$t=\infty$};
    \draw[dashed] (0,0) -- (\Xmax,-\Tmax)
        node[tlabels,black] {\mylabelstyle$t=-\infty$};     
\end{tikzpicture}

\end{document}
share|improve this answer
2  
This is such a faithful reproduction I could only tell that the picture wasn't the original by looking at the font of the labels! –  Ryan Reich Mar 29 '13 at 13:52

With PSTricks but not completed...

enter image description here

\documentclass[pstricks,border=15pt]{standalone}
\usepackage{pst-plot,pst-math}
\def\T(#1,#2){#1*SINH(#2)}
\def\X(#1,#2){#1*COSH(#2)}

\begin{document}
\begin{pspicture}(-1,-4)(4,4)
    \rput[bl](-1,-3.5){%
        \begin{pspicture*}(-1,-3.5)(3.5,3.5)
            \psset{linewidth=0.5\pslinewidth,linecolor=gray,plotpoints=500,algebraic}
            \multido{\n=-2.0+0.2}{21}{\psparametricplot{0}{4}{\X(t,\n)|\T(t,\n)}}
            \multido{\n=0.0+0.2}{21}{\psparametricplot{-2}{2}{\X(\n,t)|\T(\n,t)}}
        \end{pspicture*}}   
    \psaxes{->}(0,0)(-1,-4)(4,4)[$X$,0][$T$,90]
\end{pspicture}
\end{document}

Animation

enter image description here

\documentclass{beamer}
\usepackage{pst-plot,pst-math}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{pspicture}
\PreviewBorder=5pt

\def\T(#1,#2){#1*SINH(#2)}
\def\X(#1,#2){#1*COSH(#2)}

\begin{document}
\begin{frame}
\begin{pspicture}(-1,-4)(4,4)\pause
    \rput[bl](-1,-3.5){%
        \begin{pspicture*}(-1,-3.5)(3.5,3.5)
            \psset{linewidth=0.5\pslinewidth,linecolor=gray,plotpoints=500,algebraic}
            \multido{\n=-2.0+0.2}{21}{\psparametricplot{0}{4}{\X(t,\n)|\T(t,\n)}\pause}
            \multido{\n=0.0+0.2}{21}{\psparametricplot{-2}{2}{\X(\n,t)|\T(\n,t)}\pause}
        \end{pspicture*}}   
    \psaxes{->}(0,0)(-1,-4)(4,4)[$X$,0][$T$,90]
\end{pspicture}
\end{frame}
\end{document}
share|improve this answer
    
I've really got to get into PSTricks! Can you recommend a good (yet pedestrian) tutorial? –  Jubobs Mar 29 '13 at 13:59
1  
@Jubobs: I am preparing the free pedestrian tutorial. By the way, there are a few free PSTricks tutorials on the web, ones which are good for beginner were written by TUG India. Visit this link and locate TUG India on the right side of the two-column list. –  Who is crazy first Mar 29 '13 at 14:05

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.