我想画一条渐近线来指示蓝线遵循某条路径。但是,当我调整图的高度和宽度时,渐近线似乎发生了变化。我试图让一切都遵循坐标系。我似乎无法让一切都遵循图的坐标系。我希望箭头指向 60 度,橙色渐近线也指向 60 度。
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{siunitx}
\usepackage{pgfplotstable}
\begin{document}
\begin{center}
\pgfplotstableread[col sep=comma]{\detokenize{rlocus.dat}}\locustable
\begin{tikzpicture}[baseline=(current axis.east)]
\begin{axis}[
xmin=-6.2,xmax=1.7,ymin=-3.2,ymax=3.2,
minor tick num=1,
xtick distance=1,
ytick distance=1,
grid=both,ticks=both
]
\addplot[blue,thick] table[x index=0,y index=1]{\locustable};
\draw[dashed, orange, ultra thick] (axis cs:-1.67,0) -- ++(60:4cm);
\draw[->] (axis cs:-0.9, 0) arc (0:60:1cm) node[label={[label distance=0.01cm]0:$\SI{60}{\degree}$}] {};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
我使用了一些 Matlab 坐标来表示蓝线。我从 rlocus.dat 文件中提取这些坐标。这里列出了内容以制作 MWE。我不知道如何以其他方式给出坐标。
-0.78475,0
-0.7846,0.028256
-0.77227,0.25792
-0.74738,0.44939
-0.72046,0.59381
-0.6914,0.72116
-0.66012,0.84027
-0.62651,0.95522
-0.59046,1.0683
-0.55186,1.1811
-0.51059,1.2947
-0.46654,1.4098
-0.41957,1.5272
-0.36956,1.6475
-0.31636,1.771
-0.25984,1.8985
-0.19983,2.0302
-0.13617,2.1666
-0.068687,2.3081
0.0027904,2.4552
0.078457,2.6083
0.15851,2.7678
0.24317,2.9341
0.33264,3.1078
0.42717,3.2892
0.527,3.479
0.63239,3.6775
0.74362,3.8852
0.86097,4.1029
0.98474,4.3309
1.1153,4.5699
1.2529,4.8205
1.3979,5.0834
1.5507,5.3593
1.7118,5.6487
1.8814,5.9526
2.0601,6.2717
2.2484,6.6067
2.4466,6.9587
2.6553,7.3283
2.875,7.7167
编辑:
添加答案解决++(1cm, 0)
了\draw[->] (axis cs:-0.9, 0) arc (0:60:1cm) node[label={[label distance=0.01cm]0:$\SI{60}{\degree}$}] {};
MWE 中的问题。但它不能解决 Beamer 中的情节。当我尝试在 Beamer 中创建 MWE 时,问题也得到了解决。然而,在我的完整代码中出现了这个问题。我有以下问题:
这是我的代码(不是 MWE,因为我无法制作一个可以重现问题的代码)
\begin{frame}{Verificatie}
\begin{center}
\pgfplotstableread[col sep=comma]{\detokenize{matlab/rlocus.dat}}\locustable
\begin{tikzpicture}[baseline=(current axis.east)]
\begin{axis}[width=\framewidth,height=7.5cm,
xmin=-6.2,xmax=1.7,ymin=-2.2,ymax=2.2,
axis equal,
minor tick num=1,
xtick distance=1,
ytick distance=1,
grid=both,ticks=both
]
\addplot[only marks,thick,mark=x,color=red,mark size=5] coordinates {(0,0) (-2,0) (-3,0)};
\addplot[blue,thick,postaction={decorate}, decoration={markings, mark=at position 0.3 with {\arrow{>};}, mark=at position 0.7 with {\arrow{<};}}] coordinates {(0,0) (-2,0)};
\addplot[blue,thick,postaction={decorate}, decoration={markings, mark=at position 0.5 with {\arrow{<};}}] coordinates {(-7,0) (-3,0)};
\addplot[blue,thick,postaction={decorate}, decoration={markings, mark=at position 0.55 with {\arrow{>};}}] table[x index=0,y index=1]{\locustable};
\addplot[blue,thick,postaction={decorate}, decoration={markings, mark=at position 0.55 with {\arrow{>};}}] table[x index=0,y expr=-\thisrowno{1}]{\locustable};
\draw[<-, HRred] (axis cs:-1.67,0) -- ++(0cm,-2cm) node[below] {$s\approx-1.67$};
\draw[->, HRred] (axis cs:-0.9, 0) -- ++(1cm, 0) arc (0:60:1cm) node[label={[label distance=0.01cm]0:$\SI{60}{\degree}$}] {};
\only<2->
{
\draw[dashed, orange, ultra thick] (axis cs:-1.67,0) -- ++(60:4cm);
}
\only<3->
{
\draw[->, HRred] (axis cs:-0.9, 0) arc (0:180:1cm) node[label={[label distance=0.4cm]90:$\SI{180}{\degree}$}] {};
}
\only<4->
{
\draw[dashed, orange, ultra thick] (axis cs:-1.67,0) -- ++(180:6cm);
}
\only<5->
{
\draw[->, HRred] (axis cs:-0.9, 0) arc (0:300:1cm) node[label={[label distance=-2.2cm]0:$\SI{300}{\degree}$}] {};
}
\only<6->
{
\draw[dashed, orange, ultra thick] (axis cs:-1.67,0) -- ++(300:6cm);
}
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}
答案1
您只需要为弧线选择正确的起点即可。(对于半径为 的弧线1cm
,起点位于1cm
其中心的右侧,即橙色线的起点。)我还稍微整理了一下您的 MWE。
\begin{filecontents}{rlocus.dat}
-0.78475,0
-0.7846,0.028256
-0.77227,0.25792
-0.74738,0.44939
-0.72046,0.59381
-0.6914,0.72116
-0.66012,0.84027
-0.62651,0.95522
-0.59046,1.0683
-0.55186,1.1811
-0.51059,1.2947
-0.46654,1.4098
-0.41957,1.5272
-0.36956,1.6475
-0.31636,1.771
-0.25984,1.8985
-0.19983,2.0302
-0.13617,2.1666
-0.068687,2.3081
0.0027904,2.4552
0.078457,2.6083
0.15851,2.7678
0.24317,2.9341
0.33264,3.1078
0.42717,3.2892
0.527,3.479
0.63239,3.6775
0.74362,3.8852
0.86097,4.1029
0.98474,4.3309
\end{filecontents}
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{siunitx}
\usepackage{pgfplotstable}
\begin{document}
\begin{center}
\pgfplotstableread[col sep=comma]{\detokenize{rlocus.dat}}\locustable
\begin{tikzpicture}
\begin{axis}[
axis equal,
grid=both,
ticks=both,
]
\addplot [blue, thick] table [x index=0, y index=1] {\locustable};
\draw [dashed, orange, ultra thick] (axis cs:-1.67,0) -- ++(60:4cm);
\draw [->] (axis cs:-1.67, 0) ++(1cm, 0) arc (0:60:1cm) node [label={[label distance=0.01cm]0:\ang{60}}] {};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
显然,您会希望选择一个能够很好地适应其余图的半径。