4

I would like to make this tikz picture fancier.

enter image description here

First of all, is it possible to smooth the junction between the different parts of the graph, for istance between the half circle and the line?

Then, is it possible to color the part of the graph under the curve, i.e. between the curve and the x-axis? ONLY THIS SECOND PART WAS ALREADY ANSWERED IN A PREVIOUS QUESTION.

Here is my code until now:

\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage[]{xcolor}

\begin{document}

\begin{tikzpicture}
%\draw [help lines] (-10,0) grid [step=3] (10,10);

\draw plot [domain=0:3] (\x, {(0.7*\x)^2});
\draw plot [domain=-3:0] (\x, {(0.7*\x)^2});

\draw (4,4.41) arc (0:180:0.5);
\draw (-3,4.41) arc (0:180:0.5);

\draw plot [domain=4:10] (\x, 4.41);
\draw plot [domain=-4:-10] (\x, 4.41);

\draw [->, line width=5pt] (0,-2) -- (0,7);
\draw [->, line width=5pt] (-10,0) -- (10,0);

\draw [inner color=blue!20, outer color= blue!50!black] (0,0.5) circle (0.5);

\end{tikzpicture}
\end{document}
2
  • 3
    Coloring a part of a graph has come up many times before, I think the solution in this question would work for you. Jun 10, 2016 at 17:36
  • Dear @egreg, you marked my question as a duplicate, but no solutions were found about how to smooth the junctions between lines.
    – Andrea
    Jun 11, 2016 at 15:21

1 Answer 1

3

The reason the connection is not smooth is that the angles are different. One solution is to use the to syntax and specify an out= and in= angle and adjust them until you the results are satisfactory.

\draw [black, out=110, in =85, distance=0.70cm] (-3,4.41) to (-4.0, 4.405); 

yields on the left hand side with 1000% zoom:

enter image description here

A similar adjustment on the right hand side should work as well.

Code:

\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage[]{xcolor}

\begin{document}

\begin{tikzpicture}
%\draw [help lines] (-10,0) grid [step=3] (10,10);

\draw plot [domain=0:3] (\x, {(0.7*\x)^2});
\draw plot [domain=-3:0] (\x, {(0.7*\x)^2});

\draw [red] (4,4.41) arc (0:180:0.5);
%\draw [blue] (-3,4.41) arc (0:180:0.5);

\draw [black, out=110, in =85, distance=0.70cm] (-3,4.41) to (-4.0, 4.405);


\draw plot [domain=4:10] (\x, 4.41);
\draw plot [domain=-4:-10] (\x, 4.41);


\draw [->, line width=5pt] (0,-2) -- (0,7);
\draw [->, line width=5pt] (-10,0) -- (10,0);

\draw [inner color=blue!20, outer color= blue!50!black] (0,0.5) circle (0.5);

\end{tikzpicture}
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .