# shading area between two curves in pgfplots

I have the following latex code:

 \begin{tikzpicture}
\begin{axis}[
xlabel=Strike Price (K),
ylabel={Put Value (p)}
]
\addplot [only marks=*,blue] plot coordinates {
(40,10)
(50,20)
(70,30)
};
(40,10)
(70,30)
};
\end{axis}
\end{tikzpicture}


I want to connect the two end points with any convex function, and then shade the area in between that function and the current line, not too sure how to do this though.

You can use fillbetween library to fill the area. To make one of the curves curved, I have used smooth option.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=Strike Price (K),
ylabel={Put Value (p)}
]
\addplot [mark=*,blue,smooth,name path=A] plot coordinates {
(40,10)
(50,20)
(70,30)
};
\addplot [mark=o,red,name path=B] plot coordinates {
(40,10)
(70,30)
};
\end{axis}
\end{tikzpicture}
\end{document}


Or may be this, with the lines commented

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=Strike Price (K),
ylabel={Put Value (p)}
]
%% the upper curve
\addplot [mark=*,blue,smooth,name path=A] plot coordinates {
(40,10)
(50,20)
(70,30)
};
%% The lower curve
\addplot [no marks,green,smooth,name path=B] plot coordinates {
(40,10)
(60,15)
(70,30)
};
%% the straight line
\addplot [mark=o,red,name path=C] plot coordinates {
(40,10)
(70,30)
};
%% filling

• @dimebucker91 Add no marks in \addplot [no marks,green,smooth,name path=B] plot coordinates {... – user11232 May 4 '15 at 8:20