I would like to plot the area bounded by the following four curves:
- x^2 - y^2 = 4
- x^2 - y^2 = 1
- xy = 1
- xy = 2
I'm fond of pstricks
but tikz
is fine too, whichever is simpler would be best.
I tried doing it myself, but I can't even get as far as plotting x^2 - y^2 = c
because the y^2
is throwing me off. I've also tried looking at other examples of shading areas but it looks overly complicated.
Also, if anyone wouldn't mind annotating some lines to explain what it does so that I can try to recreate some other graphs that would be awesome, but not essential.
Herbert's answers are great, however I would like the negative side as well. I can't figure out how clipping actually works.
I've butchered Herbert's code and I'm only missing the shaded area:
\documentclass[11pt]{article}
\usepackage{pst-plot}
\begin{document}
\psset{unit=2}
\begin{pspicture}(-3.5,-3.5)(3.5,3.5)
\psaxes{->}(0,0)(-3.5,-3.5)(3.5,3.5)[$x$,-90][$y$,90]
\psset{algebraic,plotpoints=51}
\psclip[linestyle=none]{%
\pscustom{\psplot{1}{3}{1/x}\lineto(3,3)}
\pscustom{\psplot{2}{1}{sqrt(x^2-1)}\lineto(4,1)}
\pscustom{\psplot{2}{2.5}{sqrt(x^2-4)}\lineto(-1,3)}
\pscustom{\psplot{2.5}{1}{2/x}\lineto(1,-1)}
}
\psframe*[linecolor=magenta,opacity=0.3](3,3)
\endpsclip
\psplot[linecolor=red]{0.35}{3}{1/x}%
\psplot[linecolor=green]{3}{1}{sqrt(x^2-1)}%
\psplot[linecolor=yellow]{3}{2}{sqrt(x^2-4)}%
\psplot[linecolor=blue]{3}{0.65}{2/x}%
\psplot[linecolor=green]{3}{1}{-sqrt(x^2-1)}%
\psplot[linecolor=yellow]{3}{2}{-sqrt(x^2-4)}%
%\psclip[linestyle=none]{%
% \pscustom{\psplot{-0.5}{-3}{1/x}\lineto(-3,-3)}
% \pscustom{\psplot{-3}{-1}{sqrt(x^2-1)}\lineto(-4,-1)}
% \pscustom{\psplot{-3}{-2}{sqrt(x^2-4)}\lineto(-1,3)}
% \pscustom{\psplot{-3}{-0.75}{2/x}\lineto(-1,1)}
%}
% \psframe*[linecolor=magenta,opacity=0.3](0,0)(-3,-3)
%\endpsclip
\psplot[linecolor=red]{-0.35}{-3}{1/x}%
\psplot[linecolor=green]{-3}{-1}{-sqrt(x^2-1)}%
\psplot[linecolor=yellow]{-3}{-2}{-sqrt(x^2-4)}%
\psplot[linecolor=green]{-3}{-1}{sqrt(x^2-1)}%
\psplot[linecolor=yellow]{-3}{-2}{sqrt(x^2-4)}%
\psplot[linecolor=blue]{-3}{-0.65}{2/x}%
\end{pspicture}
\end{document}