我正在尝试使用 制作下图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}
- 我如何才能使注释箭头(例如指示功率的箭头)
\dot{W}
具有相同的长度? - 现在我正在指定箭头的起点和终点坐标。这意味着如果我需要移动箭头,我需要正确调整坐标。有没有办法
pos
像其他注释一样根据曲线指定? - 如何调整
s = const.
注释和相应曲线之间的间距?我想增加 3 到 4 路径之间的间距。
答案1
对于 1. 和 2.:使用以下技术阿兰·马特斯在他的一个答案中(我现在找不到),我south west
使用 键沿着每条蓝色路径放置了一个带锚点的节点pos=
;然后我使用这些节点绘制了法线(正交)线;使用shorten >=
和shorten <=
选项增加了长度。这样,就不需要使用显式坐标,并且两个箭头的长度相同。
对于 3:您可以使用yshift=
选项节点控制间距。
\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}