【问题标题】:Vertical line in 2d plot using tikzpicture使用 tikzpicture 在二维图中的垂直线
【发布时间】:2021-03-18 17:19:08
【问题描述】:

在背页上绘制后右下一行

\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 添加一条垂直线。 你能帮我解决这个问题吗?

【问题讨论】:

  • 请制作一个可编译的minimal reproducible example
  • 您的代码缺少某些部分:\documentclass\begin{document}\end{document} 和类似的。

标签: latex pdflatex overleaf


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-08
    • 2013-07-20
    • 2021-08-23
    • 1970-01-01
    • 1970-01-01
    • 2017-04-10
    • 1970-01-01
    • 2015-11-01
    相关资源
    最近更新 更多