画平行线横坐标

画平行线横坐标

我希望能够画一条与 y 轴平行的线,但我无法做到。

我尝试这个代码:

\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
    axis lines=middle,
    axis line style={->},
    x label style={at={(axis description cs:1,0)},anchor=north},
    y label style={at={(axis description cs:0.35,1)},anchor=south},
    xlabel = {Intensité I ($\unit{\mA}$)} ,
    ylabel = {Tension U ($\unit{\V}$)},
    xmin = -100, xmax = 200,
    ymin = -0.5, ymax = 13,
    xtick=\empty,]
\addplot[mark=none, red, very thick] expression[domain=-80:180]{y=100};

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

答案1

以下是两种方法阴谋一条线

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
axis line style={->},
x label style={at={(axis description cs:1,0)},anchor=north},
y label style={at={(axis description cs:0.35,1)},anchor=south},
xlabel={Intensité I ($\unit{\mA}$)} ,
ylabel={Tension U ($\unit{\V}$)},
xmin=-100, xmax=200,
ymin=-0.5, ymax=13,
xtick=\empty,
]
\addplot[mark=none, red, very thick] coordinates {(100,-0.5) (100,13)};
\addplot[mark=none, red, very thick, domain=-0.5:13, samples=2] (100,x);
\end{axis}
\end{tikzpicture}
\end{document}

带垂直线的图形

例如\draw参见pgfplots 从上到下绘制线(0% 到 100%),但给定 x 值

相关内容