Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to redraw the following graphic in pgf/TikZ.

graphic to redraw

I struggle to draw the rotated paraboloid/the root function. I come this far:

\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=1,cap=round]
    \tikzstyle{axes}=[]
    \tikzstyle{important line}=[very thick]
    \colorlet{setcolor}{green!50!black}

    % help lines
    \draw[style=help lines,step=1cm] (-4.4,-4.4) grid (4.4,4.4);

    \draw (4.4,2) parabola bend(-1,0) (4.4,-2);

    \begin{scope}[style=axes]
        \draw[->] (-4.5,0) -- (4.5,0) node[right] {$x$};
        \draw[->] (0,-4.5) -- (0,4.5);
        \draw[xshift=1 cm] (0pt,1pt) -- (0pt,-1pt) node[below,fill=white] {$1$};
        \draw[yshift=1 cm] (1pt,0pt) -- (-1pt,0pt) node[left,fill=white] {$1$};
    \end{scope}

\end{tikzpicture}
\end{center}
\end{document}

solution so far

I searched the documentation of pgf/TikZ, but am unable to find a solution.


Incorporating the solution of percusse, it is unfortunately being rendered as follows for me:

enter image description here

I am still looking into this. Maybe I need a newer version of pgf/TikZ or pgfplots.


Building on the solution of percusse, I just used a different filling method and got it working.

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{patterns}

\begin{document}
\begin{center}
  \begin{tikzpicture}
    \begin{axis}[no markers,domain=-1:2,samples=500,xmin=-2,xmax=2,y post scale=0.8,grid=major]
      \addplot[black] {sqrt(x+1)};
      \addplot[black,fill=green!20!white,opacity=.6] {-sqrt(x+1)} |- (axis cs:-1,3);
    \end{axis}
  \end{tikzpicture}
\end{center}
\end{document}

My final solution

Thank you!

share|improve this question
    
It seems from the documentation that tikx only draws parabolas like $y=x^2$, not $x = y^2$. You can rotate it in place though with \draw[rotate=-90] (-2,4.4) parabola bend(0,-1) (2,4.4); –  mrf Jun 27 '12 at 20:43
    
@mrothe: Is that the result you get from just compiling percusse's document, without any changes? –  Jake Jun 28 '12 at 8:00
    
Mine renders fine –  N3buchadnezzar Jun 28 '12 at 8:10
    
If you want to see the current version of your files, do what Gonzalo said here. Add \listfiles in your preamble, and search the log file for the version. For comparison, my version of pgfplots is pgfplots.sty v1.5.1. –  Alenanno Jun 28 '12 at 9:06
    
@Jake, yes, sorry, that's from just compiling percusse's document. –  emuso Jun 28 '12 at 11:49
show 3 more comments

2 Answers

up vote 12 down vote accepted

For such purposes pgfplots is the ideal tool.

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{patterns}

\begin{document}
\begin{tikzpicture}
\begin{axis}[no markers,domain=-1:2,samples=100,xmin=-2,xmax=2,y post scale=0.8,grid=major]
\addplot[black] {sqrt(x+1)};
\addplot[black,pattern color=red,pattern=north east lines] {-sqrt(x+1)} |- (axis cs:-1,3);
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
add comment

A possibility

\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}[x={(0,1cm)},y={(1 cm,0)}] 
  \path [domain=-2:0,pattern color=red,
         pattern=north east lines,
         fill opacity=.5] (0,-1) -- (2,-1)--(2,3) -- plot  (\x,\x*\x-1) --cycle ;  
  \draw [red,domain=-2.5:2.5,samples=100, thick]  plot (\x,\x*\x-1) ;  
    \draw[thin,blue] (-2,0) -- (2,0) ;
  \draw[thin,blue] (0,-2) -- (0,4);  
  \draw[->,thick] (0,0) -- (1,0) ;
  \draw[->,thick] (0,0) -- (0,1);        
\end{tikzpicture}
\end{document} 

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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