使线条之间的连接变得平滑

使线条之间的连接变得平滑

我想让这张 tikz 图片更加漂亮。

在此处输入图片描述

首先,是否可以平滑图形不同部分之间的连接,例如半圆和线之间的距离?

那么,是否可以为曲线下方的图形部分(即曲线和 x 轴之间)着色?只有第二部分已在上一个问题中得到解答。

到目前为止这是我的代码:

\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}

答案1

连接不顺畅的原因是角度不同。一种解决方案是使用to语法并指定out=in=角度并调整它们直到结果令人满意。

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

左侧显示缩放 1000% 后的结果:

在此处输入图片描述

右侧进行类似的调整也应该有效。

代码:

\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}

相关内容