3

I'm not entirely familiar with tikz but I want to create a drawing of a parabola, shaded (with the pattern, north west lines) and bounded. So far I've got this:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}

\draw [->] (-3,0)--(3,0) node [right] {$x$};
\draw [->] (0,-1)--(0,6) node [below left] {$y$};

\draw [ultra thick, black] (0,0) parabola(2,5) node{$\bullet$};
\draw [densely dotted] (-2,5) -- (2,5);
\draw [ultra thick, black] (0,0) parabola(-2,5) node{$\bullet$};


\draw [pattern=north west lines] (0,0) parabola (2,5);

\draw (-0.5,-0.3) node {$(0,0)$};
\draw (0,0) node{$\bullet$};

\end{tikzpicture}
\end{document}

And well, thats not exactly what I'm looking for...

And well, thats not exactly what I'm looking for as it leaves a lot of white space. If any suggestions could be made - I'm still fairly new and unexperienced, it would be much appreciated.

1
  • 1
    Welcome. // Can you please add a screenshot of your codes result to your question? (Unwanted white space etc.)
    – MS-SPO
    Jun 19 at 9:50

2 Answers 2

5

You can use parabola bend to also place the parabola vertex. A char \bullet is not guaranteed to be centered and it will depend on the font, so I use circle.

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\draw[->] (-3,0)--(3,0) node [right] {$x$};
\draw[->] (0,-1)--(0,6) node [below left] {$y$};
\draw[ultra thick, black] (-2,5) parabola bend (0,0) (2,5);
\fill (-2,5) circle[radius=2pt] (0,0) circle[radius=2pt] (2,5) circle[radius=2pt];
\draw[densely dotted, thick] (-2,5) -- (2,5);
\draw[pattern=north west lines]  (-2,5) parabola bend (0,0) (2,5);
\draw (-0.5,-0.3) node {$(0,0)$};
\end{tikzpicture}
\end{document}

Aparabola with filling

3

A small variation of @hpekristiansen answer (+1) with use patterns.meta library:

\documentclass[tikz, border=3.141592]{standalone}
\usetikzlibrary{patterns.meta}

\begin{document}
    \begin{tikzpicture}[
dot/.style = {circle, fill, node contents={},
              inner sep=1.6pt, outer sep=0pt}
                        ]
% axis
\draw[->] (-3,0.0) -- (3,0) node [below left] {$x$};
\draw[->] (0,-0.5) -- (0,6) node [below left] {$y$};
% parabola 
\draw  [thick, 
        pattern={Lines[angle=45,distance={3pt},line width=0.2pt]},
                 pattern color=gray]
       (-2,5) parabola bend (0,0) (2,5);
\draw[densely dotted, semithick] 
    (-2,5) node[dot] -- (2,5) node[dot];
% coordinate origin
\path (0,0) node[below left] {(0,0)};
\end{tikzpicture}
\end{document}

enter image description here

Edit: removed superfluous nodes dot on parabola.

5
  • +1 I did not know node[dot] - I will try tor find it in the manual and read about it. Apparently it does not work with the parabola draw. Jun 19 at 12:27
  • Ok - I first now I see that you define the dot yourself. Strange, that it does not work in the parabola draw. Jun 19 at 12:32
  • 1
    @hpekristiansen, ups, Nodes dot should not be at parabola, but only at dashed line. Adding nodes to parabola make mess in drawings patterns. So i add them do on the top of dashed area. I defined dot simple to make the code shorter and more transparent.
    – Zarko
    Jun 19 at 12:52
  • You have dots both in parabola and in dashed line. To make it work in the parabola, you need fill=black in the dot definition otherwise the pattern will be applied instead of fill. Jun 19 at 12:54
  • @hpekristiansen, you are right. By mistake I forgot to delete dot on parabola (make some experiments, and after then apparently not clean-up final code). Thank you very much to spotted this.
    – Zarko
    Jun 19 at 13:01

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.