问题描述
在背面绘制以下右侧线
\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 添加一条垂直线。 你能帮我解决这个问题吗?
解决方法
看看here,一种可能的解决方案如下:
\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}