# A hyperbolic triangle embedded in a saddle-shaped surface

This is the diagram I would like to recreate. (from https://en.wikipedia.org/wiki/Hyperbolic_triangle)

From Is there any easy way to draw a ruled surface like a hyperbolic paraboloid in TikZ?, I found a way to draw the saddle-shaped surface.

Is there a way to draw the triangle on it? And get the colours/transparency like the picture?

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\end{axis}
\end{tikzpicture}
\end{document}

• Welcome to TeX.SX! It seems that you are asking for a mathematical function for the hyperbolic triangle. If this is the case then this is the wrong page to ask that kind of question. If you would have such a function you should already have an idea of how to draw it. We could then help to fine-tune the plots so they differ from each other. Commented Aug 16, 2018 at 17:57
• Welcome, you might want to have a look at tex.stackexchange.com/questions/108915/… Commented Aug 16, 2018 at 17:59

In principle it is very simple: draw a parametric curve on the manifold and fill it.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\tikzset{declare function={%
fx(\x)=ifthenelse(\x<0,0.75*(\x+1),0.75*(-\x+1));
fy(\y)=ifthenelse(\y<0,0,ifthenelse(\y>1,-2+\y,-\y));
}}
\begin{tikzpicture}
\begin{axis}[view={-20}{45},axis lines=none,colormap/cool]
\end{axis}
\end{tikzpicture}
\end{document}
\begin{tikzpicture}
\begin{axis}[samples=41]
\end{axis}
\end{tikzpicture}


UPDATE: Tried to accommodate the requests in your comment. Please note also that the boundaries of the triangle are not pixelated on the pdf, the pixelation comes from the conversion to png.

ADDENDUM: Transparent plot with tikz-3dplot. Note, however, that the top contour is guessed. You can not easily adjust the view angles here without doing some math before.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{fillbetween}
\tikzset{declare function={%
f(\x,\y)=\x*\x-\y*\y;
fx(\x)=ifthenelse(\x<0,0.75*(\x+1),0.75*(-\x+1));
fy(\y)=ifthenelse(\y<0,0,ifthenelse(\y>1,-2+\y,-\y));
}}
\usetikzlibrary{backgrounds,calc,positioning}
\begin{document}
\pgfmathsetmacro{\xmax}{1}
\pgfmathsetmacro{\ymax}{1.5}
\foreach \X in {190}
{\tdplotsetmaincoords{130}{\X}
\begin{tikzpicture}[font=\sffamily,xscale=4,yscale=2]
%\node at (0,0) {\X};
\begin{scope}[tdplot_main_coords,samples=61,smooth,variable=\x]
\draw[name path=boundary] plot[domain=-\ymax:\ymax] (-\xmax,{\x},{f(-\xmax,\x)})
-- plot[domain=-\xmax:\xmax] (\x,{\ymax},{f(\x,\ymax})
-- plot[domain=\ymax:-\ymax] (\xmax,{\x},{f(\xmax,\x)})
-- plot[domain=\xmax:-\xmax] (\x,{-\ymax},{f(\x,-\ymax)});
\tikzset{declare function={ytop(\x)=0.35-0.2*(\x/\xmax);}}
\draw[name path=top] plot[domain=-\xmax:\xmax]  ({\x},{ytop(\x)},{f(\x,ytop(\x))});
top color=blue!80,bottom color=blue,opacity=0.3,
name path=back,
intersection segments={
of=top and boundary,
sequence={B2--A2[reverse]}
}];