2

While trying to draw a parabola in tikz I used Geogebra. But the resolution of the picture is doesn't come out to be that great as is the case in using directly tikz. The code that Geogebra generated is,

\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1.}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[->,color=black] (-4.546,0.) -- (18.454,0.);
\foreach \x in {-4.,-3.,-2.,-1.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.}
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};
\draw[->,color=black] (0.,-5.582) -- (0.,6.178);
\foreach \y in {-5.,-4.,-3.,-2.,-1.,1.,2.,3.,4.,5.,6.}
\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};
\draw[color=black] (0pt,-10pt) node[right] {\footnotesize $0$};
\clip(-4.546,-5.582) rectangle (18.454,6.178);
\draw (0.,-5.582) -- (0.,6.178);
\draw [domain=-4.546:18.454] plot(\x,{(-0.-0.*\x)/2.72});
\draw [samples=50,rotate around={-90.:(0.72,0.)},xshift=0.72cm,yshift=0.cm,domain=-11.519999999999998:11.519999999999998)] plot (\x,{(\x)^2/2/1.4399999999999997});
\draw (1.44,-5.582) -- (1.44,6.178);
\begin{scriptsize}
\draw [fill=xdxdff] (0.,0.) circle (1.5pt);
\draw[color=xdxdff] (0.134,0.278) node {$A$};
\draw[color=black] (0.214,6.038) node {$a$};
\draw[color=black] (-4.386,0.338) node {$b$};
\draw [fill=xdxdff] (1.44,0.) circle (1.5pt);
\draw[color=xdxdff] (1.574,0.278) node {$B$};
\draw [fill=uuuuuu] (1.44,1.44) circle (1.5pt);
\draw[color=uuuuuu] (1.574,1.718) node {$C$};
\draw [fill=uuuuuu] (0.72,0.) circle (1.5pt);
\draw[color=uuuuuu] (0.854,0.278) node {$D$};
\draw [fill=uuuuuu] (1.44,-1.44) circle (1.5pt);
\draw[color=uuuuuu] (1.574,-1.162) node {$E$};
\end{scriptsize}
\end{tikzpicture}
\end{document}

enter image description here

6
  • @LaRiFaRi: How did you produce this image?
    – user79095
    Jun 30 '15 at 12:49
  • Just change the number of samples. E.g. samples=100. However, your image does not fit on the page and I would use pgfplots here
    – LaRiFaRi
    Jun 30 '15 at 12:50
  • I took a screenshot and uploaded it via the "Image" button. As new user without image posting privileges simply include the image as normal and remove the ! in front of it to turn it into a link. A moderator or another user with edit privileges can then reinsert the ! to turn it into an image again.
    – LaRiFaRi
    Jun 30 '15 at 12:51
  • Why not use pgfplots?
    – Manuel
    Jun 30 '15 at 12:55
  • 1
    I could make an answer, but right now I don't have access to a compiler, and I can't remember from memory. In any case, if you don't know how to use it: that's what the documentation is for.
    – Manuel
    Jun 30 '15 at 15:28
3

I would guess you are referring to the parabola's resolution. Then, just replace samples=50 with samples=501 or similar.

3
  • Why 501 and not 500? Is there a reason or is 501 just an arbitrary number? Dec 17 '19 at 20:46
  • Just an engineers personal OCPD syndrome, I guess. When 0 is included in the position range of a sample set, and the last sample is at a “round” number such as 1000, you will have a “round” spacing only if you have this +1 sample accounting for the 0. In this case it is not important as it makes no difference for the computer, but e.g. for measurements, it is often easier to work with sample positions that have “round” numbers, if they are to be interpreted by people.
    – Chris
    Dec 18 '19 at 21:58
  • That makes perfect sense to me. Thanks! Dec 18 '19 at 23:28
2

In order to have an answer by means of pgfplots as suggested in one of the comments to your question, I worked on the following code. I have to thank Jake for his kind suggestion on his answer to a related question which I asked here.

enter image description here

%pdfLaTeX
\documentclass[border=1mm]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}

\begin{axis}
    [
    axis lines = center,
    grid=both,
    minor tick num=1,
    xlabel=$x$,ylabel=$y$,
    samples=50,
    domain=-3:3,
    ]

    \addplot [] (x^2+0.8, x);
    \addplot [dashed] (1.5,x);

    \addplot [red, mark = o] coordinates {( 1.5, 0)};
    \addplot [red, mark = o] coordinates {( 1.5, +0.837)};
    \addplot [red, mark = o] coordinates {( 1.5, -0.837)};
    \addplot [red, mark = o] coordinates {( 0, 0)};

\end{axis}

\end{tikzpicture}
\end{document}

Your Answer

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