我正在处理这种文件 .dat
t1a psi1a t1b psi1b t1c psi1c t2 psi2 t3 psi3
0.000 95.32842 0.000 99.37904 0.000 93.80294 0.000 89.99999 0.000 0.00000
0.234 95.15137 0.199 99.11545 0.252 93.66990 0.135 89.82256 0.103 0.00000
0.468 94.97408 0.397 98.85091 0.505 93.53677 0.270 89.64513 0.206 0.00000
0.703 94.79656 0.596 98.58542 0.757 93.40355 0.405 89.46770 0.309 0.00000
0.937 94.61880 0.795 98.31898 1.009 93.27024 0.540 89.29029 0.412 0.00000
1.171 94.44080 0.994 98.05160 1.261 93.13684 0.675 89.11289 0.514 0.00000
1.405 94.26258 1.192 97.78329 1.514 93.00335 0.810 88.93551 0.617 0.00000
1.640 94.08413 1.391 97.51405 1.766 92.86977 0.945 88.75814 0.720 0.00000
1.874 93.90546 1.590 97.24389 2.018 92.73610 1.080 88.58080 0.823 0.00000
2.108 93.72658 1.789 96.97283 2.270 92.60235 1.215 88.40349 0.926 0.00000
2.342 93.54747 1.987 96.70086 2.523 92.46852 1.350 88.22621 1.029 0.00000
2.577 93.36815 2.186 96.42799 2.775 92.33460 1.485 88.04897 1.132 0.00000
2.811 93.18862 2.385 96.15423 3.027 92.20060 1.620 87.87176 1.235 0.00000
3.045 93.00889 2.584 95.87960 3.279 92.06653 1.755 87.69459 1.338 0.00000
为了得到一个图,我使用了\pgfplots
环境。这里是 MWE:
\documentclass{article}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage[dvipsnames]{xcolor} %color extension
\usepackage{pgf,pgfplots,pgfplotstable}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{colormaps}
\begin{document}
\begin{figure}
\centering
\pgfplotstableread{data/psi/psit.dat}{\table}
\begin{tikzpicture}
\begin{axis}[
title = Time evolution of thrust angle $\psi$ along the trajectory,
xmin = 0, xmax = 27,
ymin = -0.5, ymax = 105,
xtick distance = 5,
ytick distance = 30,
xlabel={$time\;[s]$},
ylabel={$\boldsymbol{\psi}\;[\circ]$},
grid = both,
grid style = {dotted},
minor tick num = 1,
major grid style = {lightgray!75},
minor grid style = {lightgray!75},
width = 0.85\textwidth,
height = 0.50\textwidth,
%scale only axis,
legend cell align = {left},
legend pos = south east
]
\addplot[smooth, black, very thick] table [x = {t1a}, y = {psi1a}] {\table};
\addplot[smooth, Lavender, very thick] table [x = {t1b}, y = {psi1b}] {\table};
\addplot[smooth, Violet, very thick] table [x = {t1c}, y = {psi1c}] {\table};
\addplot[smooth, Emerald, very thick] table [x = {t2}, y = {psi2}] {\table};
\addplot[smooth, Melon, very thick] table [x = {t3}, y = {psi3}] {\table};
\legend{
n1 (k),
n1 (k+2),
n1 (k-2),
n2,
n3,
}
\end{axis}
\end{tikzpicture}
\caption{Thrust angle $\psi$ as a function of time}
\end{figure}
\end{document}
我想知道如何在 t1a、t1b、t1c、t2 和 t3 的特定域中的每个图内绘制虚线,而域的其余部分则保留实线。例如,我希望在以下对应位置绘制虚线:
t1a=0.937:1.874
t1b=1.192:2.186
t1c=0.757:2.018
t2=0:1.485
t3=0:1.132
我尝试过这个dashed
选项,通过为每个图设置一个特定的域将单个图拆分为三个不同的图,但我不知道是否有更好的选择。无论如何,在我目前的解决方案中,代码会弄乱图例,因为它考虑了三条不同的曲线,而不仅仅是一条。
我希望有人能帮助我,谢谢。