如何在弯曲的线上绘制虚线?

如何在弯曲的线上绘制虚线?

我正在尝试在 TikZ 中绘制下图: 在此处输入图片描述

但我一直面临的问题是如何在弯曲的线上绘制散列线,以及如何消除某个圆的一部分:

在此处输入图片描述

\documentclass[tikz,border=5mm]{standalone}   %<<< added
\begin{document}    %<<< added

\begin{tikzpicture}[ rotate=5, >=stealth]
\draw[fill=lightgray, opacity=0.3] (2.37,-4.1)circle(0.3);
\draw[fill=lightgray, opacity=0.3] (2.07,-1.71)circle(0.3);
\draw[fill=lightgray, opacity=0.3] (2,0)circle(0.5);
\draw[fill=lightgray, opacity=0.3] (2.18,2.8)circle(0.3);
\draw (0,0) ellipse [x radius=2, y radius=1];
\draw (0,0) ellipse [x radius=4, y radius=2];
\draw (0,0) ellipse [x radius=6.5, y radius=4];
\filldraw[black] (0,0) circle(0.02) node[left] {$x_1$};
\draw[smooth] (2.455,4.6)to[bend right=10](2.455,-4.6);
\draw[smooth, gray,thick, ->] (2,0)--(3,0);
\draw[smooth,thick, ->] (2,0)--(1,0);
\filldraw[black] (2,0)circle(0.03) node[right=0.17, above] {$x_3$};
\draw[smooth, gray,thick, ->] (4,0)--(5,0);
\filldraw[black] (2.07,-1.71)circle(0.03)node[right=0.17, above] {$x_2$};
\draw[thick, ->, black] (2.07,-1.71)--(1, -1.99);
\draw[smooth, gray,thick, ->]  (-2.07,-1.71)--(-2.3, -2.4);
\draw[smooth,thick, ->]  (2.18,2.8)--(1.1,3);
\draw[smooth,thick, ->] (2.37,-4.1)--(1.5,-4.3);
\end{tikzpicture}
\end{document}         %<<< added

我在绘制弯曲线时尝试了该fill选项,但是没有用,有没有什么解决办法,下面是我打算绘制的:

在此处输入图片描述

答案1

您可以用图案填充形状(使用patterns.meta库):

虚线弯曲区

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

\begin{document}
    \begin{tikzpicture}[ rotate=5, >=stealth]
    \begin{scope}
            \clip (2.455,4.6)to[bend right=10](2.455,-4.6) -- ([xshift=20pt]2.455,-4.6) to[bend left=10] ([xshift=20pt]2.455,4.6);
            
            \draw[fill=lightgray, opacity=0.3] (2.37,-4.1)circle(0.3);
            \draw[fill=lightgray, opacity=0.3] (2.07,-1.71)circle(0.3);
            \draw[fill=lightgray, opacity=0.3] (2,0)circle(0.5);
            \draw[fill=lightgray, opacity=0.3] (2.18,2.8)circle(0.3);
        
        \end{scope}
        
        
        \draw (0,0) ellipse [x radius=2, y radius=1];
        \draw (0,0) ellipse [x radius=4, y radius=2];
        \draw (0,0) ellipse [x radius=6.5, y radius=4];
        
        
        
        \path[fill= white,pattern={Lines[
            angle=30, 
            distance=3pt, 
            line width=0.3pt] },
            pattern color=orange] (2.455,4.6)to[bend right=10](2.455,-4.6) -- ([xshift=-20pt]2.455,-4.6) to[bend left=10] ([xshift=-20pt]2.455,4.6);
            
        \draw[smooth] (2.455,4.6)to[bend right=10](2.455,-4.6);

        
        
        
        \draw[smooth, gray,thick, ->] (2,0)--(3,0);
        \draw[smooth,thick, ->] (2,0)--(1,0);
        \filldraw[black] (2,0)circle(0.03) node[right=0.17, above right] {$x_3$};
        \draw[smooth, gray,thick, ->] (4,0)--(5,0);
        \filldraw[black] (2.07,-1.71)circle(0.03)node[right=0.17, below right] {$x_2$};
        \draw[thick, ->, black] (2.07,-1.71)--(1, -1.99);
        \draw[smooth, gray,thick, ->]  (-2.07,-1.71)--(-2.3, -2.4);
        \draw[smooth,thick, ->]  (2.18,2.8)--(1.1,3);
        \draw[smooth,thick, ->] (2.37,-4.1)--(1.5,-4.3);
    \end{tikzpicture}
\end{document}

答案2

border这可以通过使用 的装饰来实现。您可以根据需要decorations.pathreplacing设置angleamplitude和选项。segment length

在此处输入图片描述

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary {decorations.pathreplacing}

\begin{document}

\begin{tikzpicture}[ rotate=5, >=stealth, decoration={border,segment length=2mm, angle=-60, amplitude=4mm}]
\draw[fill=lightgray, opacity=0.3] (2.37,-4.1)circle(0.3);
\draw[fill=lightgray, opacity=0.3] (2.07,-1.71)circle(0.3);
\draw[fill=lightgray, opacity=0.3] (2,0)circle(0.5);
\draw[fill=lightgray, opacity=0.3] (2.18,2.8)circle(0.3);
\draw (0,0) ellipse [x radius=2, y radius=1];
\draw (0,0) ellipse [x radius=4, y radius=2];
\draw (0,0) ellipse [x radius=6.5, y radius=4];
\filldraw[black] (0,0) circle(0.02) node[left] {$x_1$};
\draw[smooth,postaction={decorate, draw}] (2.455,4.6)to[bend right=10](2.455,-4.6);
\draw[smooth, gray,thick, ->] (2,0)--(3,0);
\draw[smooth,thick, ->] (2,0)--(1,0);
\filldraw[black] (2,0)circle(0.03) node[right=0.17, above] {$x_3$};
\draw[smooth, gray,thick, ->] (4,0)--(5,0);
\filldraw[black] (2.07,-1.71)circle(0.03)node[right=0.17, above] {$x_2$};
\draw[thick, ->, black] (2.07,-1.71)--(1, -1.99);
\draw[smooth, gray,thick, ->]  (-2.07,-1.71)--(-2.3, -2.4);
\draw[smooth,thick, ->]  (2.18,2.8)--(1.1,3);
\draw[smooth,thick, ->] (2.37,-4.1)--(1.5,-4.3);
\end{tikzpicture}

\end{document}

相关内容