使用 tikzpicture 的二维图中的垂直线

问题描述

在背面绘制以下右侧线

\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}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...