Pgfplots:沿轮廓图绘制箭头

Pgfplots:沿轮廓图绘制箭头

我想在下图所示的相图中,沿着轨迹绘制“隐形”箭头来代替“0”标签。我决定使用 Pgfplots 的轮廓功能来绘制轨迹。到目前为止,我设法将标签的内部间距设置为零,但我无法弄清楚如何更改标签文本。你有什么想法吗?

在此处输入图片描述

这是我用来生成图表的代码:

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    title={Phase portrait of Van der Pol oscillator.},
    domain=-2:2,
    xmin=-2,
    xmax=2,
    ymin=-2,
    ymax=2,
    view={0}{90},
    axis background/.style={fill=white}
]

\addplot3[
    contour prepared =
    {
        contour label style = {
            inner sep = 0pt
        },
        draw color = black,
        label distance = 140pt,
        handler/.style = /tikz/smooth
    }
] table {
1   1   0
1.06298 0.924071    0
1.12034 0.837528    0
1.1715  0.742761    0
1.21604 0.642327    0
1.2537  0.53874 0
1.28439 0.434294    0
1.30815 0.330936    0
1.32515 0.230198    0
1.33561 0.133173    0
1.33981 0.0405447   0
1.33807 -0.0473723  0
1.33071 -0.130566   0
1.31803 -0.209266   0
1.30032 -0.283883   0
1.27781 -0.354957   0
1.25071 -0.423121   0
1.21919 -0.489065   0
1.18336 -0.553523   0
1.14327 -0.617253   0
1.09894 -0.681037   0
1.05031 -0.745674   0
0.997309    -0.811985   0
0.939765    -0.880811   0
0.877471    -0.953012   0
0.81016 -1.02946    0
0.737503    -1.11104    0
0.659117    -1.19857    0
0.574566    -1.2928 0
0.483372    -1.39432    0
0.385033    -1.50335    0
0.279056    -1.61961    0
0.165004    -1.742  0
0.0425688   -1.86824    0
-0.0883296  -1.99446    0
-0.227417   -2.1148 0
-0.37392    -2.22123    0
-0.526427   -2.30376    0
-0.68279    -2.35129    0
-0.84013    -2.35325    0
-0.994979   -2.30182    0
-1.14358    -2.19409    0
-1.28228    -2.03341    0
-1.40797    -1.82915    0
-1.5184 -1.59496    0
-1.61235    -1.34614    0
-1.68956    -1.09692    0
-1.75062    -0.858681   0
-1.79667    -0.639141   0
-1.82921    -0.442463   0
-1.84984    -0.269927   0
-1.86016    -0.120777   0
-1.86162    0.00698576  0
-1.85553    0.115975    0
-1.84301    0.208983    0
-1.82497    0.288714    0
-1.80219    0.357639    0
-1.77525    0.417936    0
-1.74466    0.471483    0
-1.71076    0.519882    0
-1.67385    0.56449 0
-1.6341 0.606463    0
-1.59164    0.646794    0
-1.54654    0.686352    0
-1.49881    0.725909    0
-1.44841    0.766178    0
-1.39527    0.807829    0
-1.33925    0.85152 0
-1.2802 0.89791 0
-1.21788    0.947684    0
-1.15205    1.00156 0
-1.0824 1.06031 0
-1.00855    1.12475 0
-0.930078   1.19577 0
-0.846509   1.27428 0
-0.757294   1.36121 0
-0.661824   1.45744 0
-0.559443   1.56366 0
-0.449463   1.68024 0
-0.331198   1.80687 0
-0.204031   1.94227 0
-0.0675019  2.08357 0
0.0785556   2.22577 0
0.233841    2.3611  0
0.397387    2.47881 0
0.567366    2.5655  0
0.740977    2.60659 0
0.914493    2.58894 0
1.08351 2.50416 0
1.24344 2.35155 0
1.39009 2.13913 0
1.52018 1.88231 0
1.6317  1.60044 0
1.72397 1.31283 0
1.79745 1.03554 0
1.85344 0.779751    0
1.89372 0.551697    0
1.92029 0.353461    0
1.93511 0.184222    0
1.94001 0.0414127   0
1.93657 -0.0783631  0
};

\addplot3[
    color=black!30!white,
    quiver={
        u={y},
        v={0 - x + y * (1 - x^2)},
        scale arrows=0.1
    },
    -stealth,
    samples=20
]{0};

\end{axis}
\end{tikzpicture}
\end{document}

感谢您的帮助!

答案1

在这种情况下,我不会使用contour,而是使用正常的图,并使用放置箭头decoration

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{decorations.markings}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    title={Phase portrait of Van der Pol oscillator.},
    domain=-2:2,
    xmin=-2,
    xmax=2,
    ymin=-2,
    ymax=2,
    view={0}{90},
    axis background/.style={fill=white}
]

\addplot3[
    color=black!30!white,
    quiver={
        u={y},
        v={0 - x + y * (1 - x^2)},
        scale arrows=0.1
    },
    -stealth,
    samples=20
]{0};

\addplot3[decoration={
    markings,
    mark=between positions 0.1 and 1 step 8em with {\arrow [scale=1.5]{stealth}}
    }, postaction=decorate] table {
1   1   0
1.06298 0.924071    0
1.12034 0.837528    0
1.1715  0.742761    0
1.21604 0.642327    0
1.2537  0.53874 0
1.28439 0.434294    0
1.30815 0.330936    0
1.32515 0.230198    0
1.33561 0.133173    0
1.33981 0.0405447   0
1.33807 -0.0473723  0
1.33071 -0.130566   0
1.31803 -0.209266   0
1.30032 -0.283883   0
1.27781 -0.354957   0
1.25071 -0.423121   0
1.21919 -0.489065   0
1.18336 -0.553523   0
1.14327 -0.617253   0
1.09894 -0.681037   0
1.05031 -0.745674   0
0.997309    -0.811985   0
0.939765    -0.880811   0
0.877471    -0.953012   0
0.81016 -1.02946    0
0.737503    -1.11104    0
0.659117    -1.19857    0
0.574566    -1.2928 0
0.483372    -1.39432    0
0.385033    -1.50335    0
0.279056    -1.61961    0
0.165004    -1.742  0
0.0425688   -1.86824    0
-0.0883296  -1.99446    0
-0.227417   -2.1148 0
-0.37392    -2.22123    0
-0.526427   -2.30376    0
-0.68279    -2.35129    0
-0.84013    -2.35325    0
-0.994979   -2.30182    0
-1.14358    -2.19409    0
-1.28228    -2.03341    0
-1.40797    -1.82915    0
-1.5184 -1.59496    0
-1.61235    -1.34614    0
-1.68956    -1.09692    0
-1.75062    -0.858681   0
-1.79667    -0.639141   0
-1.82921    -0.442463   0
-1.84984    -0.269927   0
-1.86016    -0.120777   0
-1.86162    0.00698576  0
-1.85553    0.115975    0
-1.84301    0.208983    0
-1.82497    0.288714    0
-1.80219    0.357639    0
-1.77525    0.417936    0
-1.74466    0.471483    0
-1.71076    0.519882    0
-1.67385    0.56449 0
-1.6341 0.606463    0
-1.59164    0.646794    0
-1.54654    0.686352    0
-1.49881    0.725909    0
-1.44841    0.766178    0
-1.39527    0.807829    0
-1.33925    0.85152 0
-1.2802 0.89791 0
-1.21788    0.947684    0
-1.15205    1.00156 0
-1.0824 1.06031 0
-1.00855    1.12475 0
-0.930078   1.19577 0
-0.846509   1.27428 0
-0.757294   1.36121 0
-0.661824   1.45744 0
-0.559443   1.56366 0
-0.449463   1.68024 0
-0.331198   1.80687 0
-0.204031   1.94227 0
-0.0675019  2.08357 0
0.0785556   2.22577 0
0.233841    2.3611  0
0.397387    2.47881 0
0.567366    2.5655  0
0.740977    2.60659 0
0.914493    2.58894 0
1.08351 2.50416 0
1.24344 2.35155 0
1.39009 2.13913 0
1.52018 1.88231 0
1.6317  1.60044 0
1.72397 1.31283 0
1.79745 1.03554 0
1.85344 0.779751    0
1.89372 0.551697    0
1.92029 0.353461    0
1.93511 0.184222    0
1.94001 0.0414127   0
1.93657 -0.0783631  0
};



\end{axis}
\end{tikzpicture}
\end{document}

相关内容