我的 MWE:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings, arrows, arrows.meta,patterns.meta}
\tikzset{
midar/.style 2 args={
very thick,
decoration={name=markings,
mark=at position .55 with {\arrow{latex}},
mark=at position 0 with {\fill circle (2pt);},
mark=at position 1 with {\fill circle (2pt);}}
,postaction=decorate,
},
}
\begin{document}
\begin{tikzpicture}[thick]
\draw[-{Latex}] (0,0) -- (0,5) node[above] {$P$};
\draw[-{Latex}] (0,0) -- (5,0) node[right] {$V$};
\draw[dashed] (0,4) node[left] {$P_{1}$} -| (1,0) node[below] {$V_{1}$};
\draw[dashed] (0,1) node[left] {$P_{2}$} -| (4,0) node[below] {$V_{2}$};
\draw (1,4) node[above left]{1};
\draw (4,1) node[above right]{2};
\draw[midar] (1,4) arc (180:270:3 and 3);
\end{tikzpicture}
\end{document}
这是我从代码中得到的图片:
这是我正在尝试做的事情的一个想法:
答案1
答案2
如果您知道情节的功能,则可以使用另一种可能性fillbetween
:
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{arrows.meta,patterns}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel={V},
ylabel={P},
yticklabels={,,},
ytick style={draw=none},
xticklabels={,,},
xtick style={draw=none},
samples=200,
axis lines=center,
ymin=0,xmin=0,
ymax=10,xmax=10,
no marks,
every axis x label/.style={
at={(ticklabel* cs:1.05)},
anchor=west,
},
every axis y label/.style={
at={(ticklabel* cs:1.05)},
anchor=south,
},
]
\addplot[blue,domain=2:4,name path=A] {15*e^(-0.4*x)+2}; %plot
\addplot[blue,domain=2:3,-Stealth] {15*e^(-0.4*x)+2}; %arrow plot
\addplot+[black,domain=2:4,name path=B] {0}; % dummy plot
\addplot+[pattern=north east lines,pattern color=red!60!white] fill between[of=A and B,soft clip={domain=2:4}]; % fillingbetween A and B
\addplot+[dashed,black,domain=0:2] {8.74};
\addplot+[dashed,black,domain=0:4] {5.03};
\addplot+[black,ycomb] coordinates {(2, 8.74)};
\addplot+[black,ycomb] coordinates {(4, 5.03)};
\coordinate (m1) at (axis cs:2,8.74); %mark1
\coordinate (m2) at (axis cs:4,5.03); %mark2
\end{axis}
\filldraw[fill=blue,draw=blue] (m1) circle(0.05) node[above] {\small 1};
\filldraw[fill=blue,draw=blue] (m2) circle(0.05) node[right] {\small 2};
\end{tikzpicture}
\end{document}
答案3
编辑:
修正函数域,添加声明函数f(x)
并添加了图表中缺失的元素。
变体 @Roland 回答使用patterns.meta
库和稍微短一点的代码:
\documentclass[border=3.141592]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{arrows.meta,
decorations.markings,
patterns.meta}
\begin{document}
\begin{tikzpicture}[
->-/.style = {decoration={%
name=markings,
mark=at position 0.5 with {\arrow{Stealth}}},
postaction=decorate},
dot/.style = {circle, fill=blue, inner sep=0pt, minimum size=4pt,
node contents={}},
]
\begin{axis}[
declare function = {f(\x)=(12*e^(-1.4*\x)+1);},
axis lines=middle,
xlabel=$V$, x label style={anchor=west},
ylabel=$P$, y label style={anchor=south},
xtick=\empty,
ytick=\empty,
xmin=0, xmax=5,
ymin=0, ymax=5,
clip=false,
domain=1:4,
every axis plot post/.append style={very thick, blue}
]
\addplot [name path=A] {f(x)}; %plot
\addplot [draw=none, name path=B] {0}; % x-domain
\addplot +[pattern={Lines[angle=45,distance={3pt}, line width=0.2pt]},
pattern color=red]
fill between[of=A and B]; % patterns
\addplot [->-] {f(x)}; % for arrow on the middle of curve
%
\draw[densely dashed] (0,{f(1)}) node[left] {$P_1$}
-| (1,0) node[below] {$V_1$} node[pos=0.5,dot,dot,label=1];
\draw[densely dashed] (0,{f(4)}) node[left] {$P_2$}
-| (4,0) node[below] {$V_2$} node[pos=0.5,dot,dot,label=2];
\end{axis}
\end{tikzpicture}
\end{document}