I want to plot the region of 0 < x2 - y2 <= 1.

I have done it in WolframAlpha, and it shows like ....

Enter image description here

How can I plot the above in LaTeX?

  • 4
    You should have a look at the pgfplots package. It has an excellent manual that will get you started. Once you have dug into it a bit, you can come back should you have more specific questions :) The manual can be found at ftp.fau.de/ctan/graphics/pgf/contrib/pgfplots/doc/pgfplots.pdf
    – Raven
    Jul 23 at 8:46
  • 1
    By the way: The plot from WA is quite ugly. It tries to camouflage the symmetries of the area. Jul 23 at 9:01

You could do if whit pgfplots as Raven suggests or with tikz (there are more options too) as in my example.

I use a \foreach command because the region to plot and the curves are both symmetric, so I avoid repeated code.


  % grid
  \draw[help lines] (-\xmax,-\xmax) grid (\xmax,\xmax);
  % axes
  \draw[-latex] (-\xmax,0) -- (\xmax,0) node [right] {$x$};
  \draw[-latex] (0,-\xmax) -- (0,\xmax) node [above] {$y$};
  % a little bit of the hyperbola goes out of the grid so I'm clipping it
  \clip (-\xmax,-\xmax) rectangle (\xmax,\xmax);
  \foreach\i in {-1,1} % to draw the following twice
    \draw[thick,blue,fill=yellow,fill opacity=0.4] (0,0) -- (\i*\xmax,-\xmax)
          -- plot[smooth,domain=-\xmax:\xmax] ({\i*sqrt(1+\x*\x)},\x)
          -- (\i*\xmax,\xmax) -- cycle;                                   % curve(s) and yellow regoin(s)
    \draw[thick,red] (\i*\xmax,-\xmax) -- (0,0) --  (\i*\xmax,\xmax);     % asymptote(s)

enter image description here Edit: I changed the code a little bit, drawing the curve and filling the region at the same time.


If you compile this:


you will get this:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.