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.

I am trying to make the following figure using pgfplots.

\documentclass{article}

\usepackage{pgfplots}
    \pgfplotsset{width=8cm,compat=1.5.1}
    \usetikzlibrary{decorations.markings}    % Arrows

\usepackage{caption}

\begin{document}

\noindent
\begin{minipage}{\linewidth}

    \centering
    \begin{tikzpicture}[scale=1]
    \begin{axis}[ axis lines=left,
                  xmin=-.1, xmax=1.9,   ymin=-1, ymax=22,
                  xlabel={$v$},         ylabel={$p$},
                  xtick =\empty,        ytick=\empty,
                ]
        % Compression (Work in)
        \addplot[blue, domain=0.85:0.1,    samples = 20, postaction={decorate},
                decoration={markings, mark=at position 0.6 with {\arrow{>}}}
               ] { (0.85/x)^(1.4) }
               [sloped, font=\small]
               node[below, pos=0.7] {$s =$ const.};

        % Heat addition
        \addplot[ red, postaction={decorate},
                  decoration={markings, mark=at position 0.65 with {\arrow{>}}}
                ]
                coordinates{ (0.1,20) (0.2,20)}
                [ every node/.style={font=\small, text = black} ]
                    node[ left, pos = 0] {2}
                    node[right, pos = 1] {3};

        % Expansion (Work out)
        \addplot[ blue,domain=0.2:1.7, samples = 40, postaction={decorate},
                  decoration={markings, mark=at position 0.32 with {\arrow{>}}}
                ] { (1.7/x)^(1.4) }
               [sloped, font=\small]
               node[above, pos=0.3] {$s =$ const.};

        % Heat removal
        \addplot[ red, postaction={decorate},
                  decoration={markings, mark=at position 0.6 with {\arrow{>}}}
                ]
                coordinates{ (1.7,1) (0.85,1) }
                [ every node/.style={font=\small, text = black} ]
                    node[below, pos = 0] {4}
                    node[below, pos = 1] {1};

        \draw[blue, -latex, line width = 1pt] (axis cs:0.15,5.5) -- (axis cs:0.35,7)
        node[anchor = north east, pos=0.5, font=\footnotesize] {$\dot{W}_{\textrm{in}}$};

        \draw[blue, -latex, line width = 1pt] (axis cs:0.4,5.5) -- (axis cs:0.6,7)
        node[anchor = west, pos=0.9, font=\footnotesize] {$\dot{W}_{\textrm{out}}$};

    \end{axis}
    \end{tikzpicture}
    \captionof{figure}{Ideal Brayton cycle}
\end{minipage}

\end{document}

enter image description here

  1. How can I get the annotation arrows (the one that indicate power e.g. \dot{W} to be of same length?
  2. Right now I am specifying the start and end point co-ordiantes of the arrows. This means that if I need to move the arrow, I need to tweak the co-ordinates correctly. Is there a way to specify based on pos on the curve like that other annotations?
  3. How can I adjust the spacing between the s = const. annotation and the corresponding curve? I would like to increase the spacing from the 3-to-4 path.
share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

For 1. and 2.: using a technique exposed by Alain Matthes in one of his answers (that I cannot find right now), I placed a node with south west anchor along each one of the blue paths using the pos= key; then I used those nodes to draw normal (orthogonal) lines; the length was increased using the shorten >= and shorten <= options. In this way, there's no need to use explicit coordinates and the length for both arrows is the same.

For 3: you can use the yshift= option to the nodes control the spacing.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{width=8cm,compat=1.5.1}
\usetikzlibrary{decorations.markings}    % Arrows
\usepackage{caption}

\begin{document}

\noindent
\begin{minipage}{\linewidth}

\centering
\begin{tikzpicture}[scale=1]
\begin{axis}[ axis lines=left,
  xmin=-.1, xmax=1.9,   ymin=-1, ymax=22,
  xlabel={$v$},         ylabel={$p$},
  xtick =\empty,        ytick=\empty,
]
        % Compression (Work in)
\addplot[blue, domain=0.85:0.1,    samples = 20, postaction={decorate},
  decoration={markings, mark=at position 0.6 with {\arrow{>}}}
] 
{ (0.85/x)^(1.4) }
  [sloped, font=\small]
  node[below, pos=0.7,yshift=-3pt] {$s =$ const.} node[above,pos=0.15,anchor=south west] (L) {};

        % Heat addition
\addplot[ red, postaction={decorate},
  decoration={markings, mark=at position 0.65 with {\arrow{>}}}
] 
coordinates{ (0.1,20) (0.2,20)}
  [ every node/.style={font=\small, text = black} ]
  node[ left, pos = 0] {2}
  node[right, pos = 1] {3};

        % Expansion (Work out)
\addplot[ blue,domain=0.2:1.7, samples = 40, postaction={decorate},
  decoration={markings, mark=at position 0.32 with {\arrow{>}}}
] 
{ (1.7/x)^(1.4) }
  [sloped, font=\small]
  node[above, pos=0.3,yshift=5pt] {$s =$ const.} node[above,pos=0.7,anchor=south west] (M) {};

        % Heat removal
\addplot[ red, postaction={decorate},
  decoration={markings, mark=at position 0.6 with {\arrow{>}}}
]
coordinates{ (1.7,1) (0.85,1) }
  [ every node/.style={font=\small, text = black} ]
  node[below, pos = 0] {4}
  node[below, pos = 1] {1};

\draw[-latex,blue,line width = 1pt,shorten >= -5pt,shorten <=-5pt] 
  (M.south west) -- (M.north west) 
  node[anchor = west, font=\footnotesize,xshift=3pt] {$\dot{W}_{\textrm{out}}$};        

\draw[-latex,blue,line width = 1pt,shorten >= -5pt,shorten <=-5pt] 
    (L.south west) node[anchor = east, font=\footnotesize,xshift=-3pt] {$\dot{W}_{\textrm{in}}$} 
  -- (L.north west);        

\end{axis}
\end{tikzpicture}
\captionof{figure}{Ideal Brayton cycle}
\end{minipage}

\end{document}

enter image description here

share|improve this answer
    
you assumed right. i have edited the question to clarify that. thank you. –  mythealias Sep 20 '12 at 0:58
    
@mythealias ah, OK. I removed the initial remark from my answer. –  Gonzalo Medina Sep 20 '12 at 1:15
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.