I'm trying to plot the domain bounded by the hyperbola x^2/2-y^2/4=1
, the parabola y^2=2x
, and the lines y=0
, y=1
.
I have plotted all these curves, by using the code:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{figure}[h]
\begin{tikzpicture}
\begin{axis}
[xlabel=$x$,ylabel=$y$,
xtick={100},ytick={100},
no marks,axis equal,axis lines=middle,
xmin=-9,xmax=8,ymin=-8,ymax=8,
enlargelimits={upper=0.1}]
\addplot[color=black, no markers,samples=1001, samples y=0, domain=-6:6, variable=t]( {sqrt(t^2+4)/sqrt(2)}, {t} );
\addplot[color=black, no markers,samples=1001, samples y=0, domain=-6:6, variable=t]( {-sqrt(t^2+4)/sqrt(2)}, {t} );
\addplot[color=black, no markers,samples=1001, samples y=0, domain=-4:4, variable=t]( {t^2/2}, {t} );
\addplot[color=black, no markers,samples=1001, samples y=0, domain=-2:3, variable=t]( {t}, {0} );
\addplot[color=black, no markers,samples=1001, samples y=0, domain=-7:7, variable=t]( {t}, {1} );
\draw node[below left] at (0,0) {\scalebox{0.75}{$O$}};
\draw node[above left] at (0,1) {\scalebox{0.75}{$1$}};
\draw node[above] at (6,1) {\scalebox{0.75}{$y=1$}};
\draw node[below] at (7,0) {\footnotesize{$y=0$}};
\draw node[right] at (6.5,4.5) {\scalebox{0.75}{$y^2=2x$}};
\draw node[right] at (2,-6.8) {\scalebox{0.75}{$x=\sqrt{y^2+4)/2}$}};
\draw node[left] at (-2,-6.8) {\scalebox{0.75}{$x=-\sqrt{y^2+4)/2}$}};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
How can I shade the desired domain, by using TikZ, in order to point it out ?
pgfplotslibrary
fillbetween
. – bmv Dec 21 '17 at 12:45node[..]{..}
at the end of an\addplot
, so you don't need the separate\draw node..
lines. See example at gist.github.com/TorbjornT/4cd1f662c61b2ec07e72bae079d0a859 – Torbjørn T. Dec 21 '17 at 13:21