13

I am trying to draw a p,T-diagram with TikZ using pgfplots as shown in the picture. All I have so far is:

\documentclass[a4paper, 11pt]{scrartcl}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{decorations.text}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
    scale=1.5,
    ticks=none,
    axis lines = left,
    axis line style={shorten >=-10pt},
    xlabel={Temperatur $T$},
    ylabel={Druck $p$},
    xmax=100,
    ymax=100,
]
\addplot [
    no markers,
    domain=0:28.3, 
    samples=100, 
    color=black,
    style=solid,
    line width=1pt,
    postaction={
        decorate,
        decoration={
            text along path,
            text={|\scriptsize| Sublimationsdruckkurve},
            raise=1ex,
            text align={center},
            }
        },
    ]
    {37/104976*x^3 + 25/5832*x^2};
\addplot [
    no markers,
    domain=28.3:54, 
    samples=100, 
    color=black,
    style=solid,
    line width=1pt,
    postaction={
        decorate,
        decoration={
            text along path,
            text={|\scriptsize| Dampfdruckkurve},
            raise=1ex,
            text align={center}
            }
        },
    ]
    {37/104976*x^3 + 25/5832*x^2};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(9.86,37/104976*9.86^3 + 25/5832*9.86^2)(11.3,100)};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    line width=1pt,
    postaction={
        decorate,
        decoration={
            text along path,
            text={|\scriptsize| Schmelzdruckkurve},
            raise=1ex,
            text align={center}
            }
        },
    ]
    coordinates{(18.9,37/104976*18.9^3 + 25/5832*18.9^2)(21.5,100)};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(28.3,37/104976*28.3^3 + 25/5832*28.3^2)(31.5,100)};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(35.7,37/104976*35.7^3 + 25/5832*35.7^2)(39.9,100)};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(45.0,37/104976*45.0^3 + 25/5832*45.0^2)(49.4,100)};
\addplot [
    no markers,
    domain=54:100, 
    samples=100, 
    color=black,
    style=solid,
    ]
    {37/104976*x^3 + 25/5832*x^2};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(16.9,37/104976*16.9^3 + 25/5832*16.9^2)(100,7.23)};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(30.9,37/104976*30.9^3 + 25/5832*30.9^2)(100,28.0)};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(37.6,37/104976*37.6^3 + 25/5832*37.6^2)(100,48.5)};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(42.2,37/104976*42.2^3 + 25/5832*42.2^2)(100,66.4)};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(47.0,37/104976*47.0^3 + 25/5832*47.0^2)(100,89.0)};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(50.6,37/104976*50.6^3 + 25/5832*50.6^2)(80.8,100)};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

I am struggeling with the text for the isochoric lines, the x axis ticks for T_tr and T_K and the axis symbols p and T left and below the arrows. Besides, the text above the curves should not overlap with other lines. I am missing a background option. Maybe somebody can help me out?

p,T-diagram

  • As the lines are, well, just lines, you don't need \addplot, you can use \draw like this: \draw (x_1,y_1) -- (x_2,y_2) node[above, sloped, pos=0.5] {$z=4n$}; – Tom Bombadil Nov 27 '15 at 14:46
11

This is fairly close.

  • The axis labels have been moved by modifying the every axis x label and every axis y label styles, see the axis options.

  • Ticks are added by changing ticks=none to ytick=\empty and adding xtick={28.9,54},xticklabels={$T_{\mathrm{Tr}}$, $T_{\mathrm{K}}$}. The dashed lines are drawn with a ycomb plot, see the last \addplot.

  • The labels on the lines are added with node[pos=<fraction>,sloped,above]{$v=Nv_K$};. Some trial and error to get nice values for pos.

  • Two postactions to get Sublimationsdruckkurve in two lines. To avoid the overprinting of the line, I added a shorten <=5ex to the offending \addplot. Similar for the line over Dampfdruckkurve.

  • Nodes with pin or label added to get the Tripelpunkt and K labels.

  • Festkörper, Flussigkeit and Gasphase are added as nodes filled with white (see end of axis environment).

enter image description here

\documentclass[a4paper, 11pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{decorations.text}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
    scale=1.5,
    ytick=\empty,
    axis lines = left,
    axis line style={shorten >=-10pt},
    xlabel={Temperatur $T$},
    ylabel={Druck $p$},
    xmax=100,
    ymax=100,
    xtick={18.9,54},
    xticklabels={$T_{\mathit{tr}}$, $T_{K}$},
    every axis x label/.style={anchor=north east,at={(1,0)},xshift=10pt},
    every axis y label/.style={anchor=north east,at={(0,1)},yshift=10pt},
]
\addplot [
    no markers,
    domain=0:18.9, 
    samples=100, 
    color=black,
    style=solid,
    line width=1pt,
    postaction={
        decorate,
        decoration={
            text along path,
            text={|\scriptsize| Sublimations-},
            raise=3ex,
            text align={center},
            },
        },
    postaction={
        decorate,
        decoration={
            text along path,
            text={|\scriptsize| druckkurve},
            raise=1ex,
            text align={center},
            },
        },
    ]    {37/104976*x^3 + 25/5832*x^2} node[inner sep=0pt,pin={[pin distance=1cm,font=\scriptsize,inner sep=1pt]3:Tripelpunkt}]{};
\addplot [
    no markers,
    domain=18.9:54, 
    samples=100, 
    color=black,
    style=solid,
    line width=1pt,
    postaction={
        decorate,
        decoration={
            text along path,
            text={|\scriptsize| Dampfdruckkurve},
            raise=1ex,
            text align={center},
            }
        },
    ]
    {37/104976*x^3 + 25/5832*x^2} node[inner sep=0pt,label={[font=\footnotesize]10:$K$}]{};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    shorten <=5ex
    ]
    coordinates{(9.86,37/104976*9.86^3 + 25/5832*9.86^2)(11.3,100)} node[pos=0.9,sloped,above] {$v=\mathrm{const.}$};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    line width=1pt,
    postaction={
        decorate,
        decoration={
            text along path,
            text={|\scriptsize| Schmelzdruckkurve},
            raise=1ex,
            text align={center},
            }
        },
    ]
    coordinates{(18.9,37/104976*18.9^3 + 25/5832*18.9^2)(21.5,100)};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(28.3,37/104976*28.3^3 + 25/5832*28.3^2)(31.5,100)} node[pos=0.8,sloped,above]{$v=0.4v_k$};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    shorten <=6ex
    ]
    coordinates{(35.7,37/104976*35.7^3 + 25/5832*35.7^2)(39.9,100)} node[pos=0.77,sloped,above]{$v=0.5v_k$};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(45.0,37/104976*45.0^3 + 25/5832*45.0^2)(49.4,100)} node[pos=0.7,sloped,above]{$v=0.7v_k$};
\addplot [
    no markers,
    domain=54:100, 
    samples=100, 
    color=black,
    style=solid,
    ]
    {37/104976*x^3 + 25/5832*x^2} node [pos=0.05,sloped,above] {$v=v_k$};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(16.9,37/104976*16.9^3 + 25/5832*16.9^2)(100,7.23)} node[pos=0.8,sloped,above]{$v=40v_k$};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(30.9,37/104976*30.9^3 + 25/5832*30.9^2)(100,28.0)} node[pos=0.75,sloped,above]{$v=10v_k$};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(37.6,37/104976*37.6^3 + 25/5832*37.6^2)(100,48.5)}node[pos=0.7,sloped,above]{$v=6v_k$};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(42.2,37/104976*42.2^3 + 25/5832*42.2^2)(100,66.4)}node[pos=0.65,sloped,above]{$v=4v_k$};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(47.0,37/104976*47.0^3 + 25/5832*47.0^2)(100,89.0)}node[pos=0.55,sloped,above]{$v=3v_k$};
\addplot+[
    smooth,
    no markers,
    color=black,
    style=solid,
    ]
    coordinates{(50.6,37/104976*50.6^3 + 25/5832*50.6^2)(80.8,100)} node[pos=0.6,sloped,above]{$v=2v_k$};


\addplot [black,mark=*,mark options={draw=black,solid,fill=white},densely dashed,ycomb,samples at={18.9,54}] {37/104976*x^3 + 25/5832*x^2};

\node [align=center,fill=white] at (rel axis cs:0.1,0.7){Fest-\\körper};
\node [align=center,fill=white] at (rel axis cs:0.35,0.55){Flüssigkeit};
\node [align=center,fill=white] at (rel axis cs:0.7,0.36){Gasphase};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
  • Thank you very much. Your solution is perfect and you really helped me out. – Yannick Nov 30 '15 at 8:34

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.