9

My 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}

This is the picture that I get from the code:

enter image description here

This is an idea for what I'm trying to do:

enter image description here

Roland
  • 6,655
  • 1
    In addition to providing us with code fragments in your question, consider also submitting the complete code that can be compiled to produce the shown output. The complete code is also called as Minimal Working Example (MWE). So we don't need to reassemble your code fragments. – Display Name May 05 '21 at 23:50

3 Answers3

12

Append the following code at the end of the tikzpicture environment

\fill[pattern=north east lines, pattern color=red] (4,0) -- (1,0) -- (1,4) arc (180:270:3 and 3) -- cycle;

Of course, you need to add \usetikzlibrary{patterns} in your preamble.

enter image description here

Ukiyo-E
  • 728
11

Another possibility if you know the function of your plot you can use 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] {15e^(-0.4x)+2}; %plot \addplot[blue,domain=2:3,-Stealth] {15e^(-0.4x)+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}

enter image description here

Roland
  • 6,655
5

Edit: corrected function domain, added declared function f(x) and added missed elements of diagram.

A variation of @Roland answer with use of the patterns.meta library and a wee bit shorter code:

\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)=(12e^(-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}

enter image description here

Zarko
  • 296,517