I am interested in drawing the minimum and the maximum of two variables, i.e. min(x,y)
or max(x,y)
. The way I was going about doing it so far was to get the contour plots using gnuplot but my attempts have not been successful.
The plots do not show well and I am not quite sure what the reason is. Here is what the code at the end of my post produces:
This is far from the actual functions, unfortunately. The maximum should be a square and the minimum two orthogonal lines as in the plot below.
Could you please help me reproduce these functions, if possible by adjusting my code?
Thank you in advance.
\documentclass[11pt,a4paper]{article}
\usepackage{fullpage}
\usepackage{graphicx}
\usepackage{indentfirst}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage[miktex]{gnuplottex}
\pgfplotsset{compat=1.12}
\usepackage{amsmath}
\usepackage{natbib}
\usepackage{amssymb}
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{
colorlinks,
linkcolor={red!50!black},
citecolor={black!50!black},
urlcolor={blue!80!black}
\begin{document}
\begin{tikzpicture}[scale=0.8]
\begin{axis}[
axis lines=left,
view={0}{90},
xlabel=$P_1$,
ylabel=$P_2$,
xmin=0,xmax=1,
ymin=0,ymax=1,
]
\addplot3[
contour gnuplot={levels={0.02}}
]
{min(x,y)};
\end{axis}
\end{tikzpicture}\begin{tikzpicture}[scale=0.8]
\begin{axis}[
axis lines=left,
view={0}{90},
xlabel=$P_1$,
ylabel=$P_2$,
xmin=0,xmax=1,
ymin=0,ymax=1,
]
\addplot3[
contour gnuplot={levels={0.2}}
]
{max(x,y)};
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
Add the
domain
andsamples
to the\addplot3
options.