TikZ-figure 的三处改动

TikZ-figure 的三处改动

我使用 TikZ 和 pgfplots 创建了一个图形,如下所示:

数字

我尝试使用 TikZ 和 pgfplot 包的文档,但无法实施更改。 我想要做的更改是:

  • 平移表示波浪方向的箭头,使其仍然垂直于蓝线,但同时经过原点。

  • 逆时针延伸表示角度 theta 的弧,以到达波浪方向箭头。换句话说,使得 theta 定义在正 x* 轴和波浪方向箭头之间。

  • 沿 x 轴拉长椭圆-方向,使其变得更加“椭圆”,而不会在上方和下方留下太多空白空间(沿 y-轴)。

我目前所做的:

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
% Defining TikZ-package libraries
% -------------------------------------------
\usetikzlibrary{intersections,
                calc,
                fit,
                angles}
\usetikzlibrary{arrows.meta,
                patterns,
                pgfplots.fillbetween}
% -------------------------------------------

% Adjust pgfplots package
% -------------------------------------------
\pgfplotsset{compat=1.17} % Always used with pgfplots-package.
\pgfdeclarelayer{ft} % Front layer.
\pgfdeclarelayer{bg} % Background layer.
\pgfsetlayers{bg,main,ft} % Set of all the layers. Main is defined as standard.
% -------------------------------------------
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[domain=-9:9,
                    axis lines=middle,
                    inner axis line style={->,>=latex},
                    xlabel={$x^*$}, ylabel={$y^*$},
                    xlabel style={anchor=west},
                    ylabel style={anchor=south},
                    ticks=none,
                    xmin=-9, xmax=9,
                    ymin=-4.1, ymax=4.1,
                    clip mode=individual]
            \draw (0,0) ellipse (8 and 3);
            \addplot[blue]{0.4*x};
            \addplot[blue]{0.4*x+1.2};
            \addplot[blue]{0.4*x+2.4};
            \addplot[blue]{0.4*x+3.6};
            \addplot[blue]{0.4*x+4.8} node [above,sloped,pos=0.2,black] {Wave direction};
            \addplot[blue]{0.4*x+6};
            \addplot[blue]{0.4*x+7.2};
            \addplot[blue]{0.4*x-1.2};
            \addplot[blue]{0.4*x-2.4};
            \addplot[blue]{0.4*x-3.6};
            \addplot[blue]{0.4*x-4.8};
            \addplot[blue]{0.4*x-6};
            \addplot[blue]{0.4*x-7.2};
            \draw [->,>=latex] (2.5,0) arc (0:{atan(0.1/0.25)}:2.5) node [pos=0.12]{$\theta$};
            \coordinate (A) at (-9,1.2);
            \coordinate (B) at (-1.75,4.1);
            \path (A) -- (B) coordinate[midway] (M);
            \draw[->,>=latex] ($(M)!1.75cm!90:(A)$) -- ($(M)!0cm!270:(A)$);
        \end{axis}
    \end{tikzpicture}
\end{document}

答案1

使用普通的 TikZ,你可以编码

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{
    arrows,
}


\begin{document}
    \begin{tikzpicture}[>=latex']
    \pgfmathsetmacro\ang{120}
    \pgfmathsetmacro\rr{.6}
    \pgfmathsetmacro\Wave{6}
    \pgfmathsetmacro\nn{14}
    \draw [thick, ->] (-9, 0) -- (9, 0) node [right=3pt] {$x^*$};
    \draw [thick, ->] (0, -4.1) -- (0, 4.1) node [above=3pt] {$y^*$};
    \draw (0, 0) ellipse [x radius=6, y radius=2];
    \begin{scope}
    \clip (-8.5, -3.5) rectangle (8.5, 3.5);
    \foreach \n in {-\nn,...,\nn}
    {
        \draw[blue, xshift=\n cm] (\ang-90:-\Wave) -- (\ang-90:\Wave);
    }
    \end{scope}
    \draw [very thick, ->, red] (0, 0) -- (\ang:3) node [pos=1.1, rotate=\ang-90] {Wave direction};
    \draw [->] (0:\rr) arc [start angle=0, end angle=\ang, radius=\rr] node [pos=.5, anchor=south west] {$\theta$};
    \end{tikzpicture}
\end{document}

这使在此处输入图片描述

相关内容