我想在绘制的点上画一条红线。我做错了什么?
以下是代码:
\begin{figure}[!ht]
\centering\
\begin{tikzpicture}
\begin{axis}[
ymin=0, ymax=4.75,
xmin=0, xmax=14.5,
grid,
xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14},
ytick={0,0.5,1,1.5,2,2.5,3,3.5,4,4.5},
xlabel={Velocidad [rad/s]},
ylabel={Tensión DC [V]},
width=\textwidth,
height=0.7\textwidth,
]
\addplot[only marks,mark size = 0.4pt,
mark options={teal}] table[x=vel_dec, y=v_DC_dec,col sep=semicolon]{k_E_DCPM.csv};
\draw[red, ultra thick, domain=0.2997:12.5188] plot (\x,{0.321210875886567*\x});
\end{axis}
\end{tikzpicture}
\caption{Tensión generada en terminales en función de la velocidad del rotor de la máquina DCPM}
\label{fig:k_E_DCPM}
\end{figure}
这是我得到的输出:
提前致谢。
答案1
你可以clip mode=individual
这样使用:
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=0, xmax=14.5,
ymin=0, ymax=4.75,
grid,
xtick distance=1, ytick distance=0.5,
xlabel={Velocidad [rad/s]},
ylabel={Tensión DC [V]},
clip mode=individual,
]
\addplot[teal, only marks]{0.33*x};
\draw[red, ultra thick, domain=0.2997:12.5188, samples=2] plot (\x,{0.321210875886567*\x});
\end{axis}
\end{tikzpicture}
\end{document}