0

在背面绘制以下右线后

\begin{tikzpicture}
\begin{axis}[
    axis lines = left,
    xlabel = $x$,
    ylabel = {$f(x)$},
]
%Below the red parabola is defined
\addplot [
    domain=-10:10, 
    samples=100, 
    color=red,
]
{((6*x - 48)/8)};
\addlegendentry{$6x + 8y = 48$}

我需要在同一个图上为 x = 6 添加一条垂直线。你能帮我解决这个问题吗?

4

1 回答 1

4

看看这里,一种可能的解决方案如下:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    axis lines = left,
    xlabel = $x$,
    ylabel = {$f(x)$},
]
%Below the red parabola is defined
\addplot [
    domain=-10:10, 
    samples=100, 
    color=red,
]
{((6*x - 48)/8)};

%% This is the vertical line
\addplot[thick, samples=50, smooth,domain=0:6,magenta] coordinates {(6,0)(6,-15)};

\addlegendentry{$6x + 8y = 48$}
% Added to the legend
\addlegendentry{$x = 6$}
\end{axis}
\end{tikzpicture}

\end{document}
于 2021-03-18T17:31:14.303 回答