在 Tikz 中将线延伸至 y 轴

在 Tikz 中将线延伸至 y 轴

我有一张带有两行的简单 tikzpicture。以下是 Latex 代码:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}

\begin{tikzpicture}[scale=1.0]
\definecolor{ggreen}{cmyk}{1,0.2,1,0.2}
\draw[font={\fontsize{9pt}{9}\selectfont},-latex,line width=0.75pt] (0,0)--(8,0) coordinate[pos=0.9,label={below:Accuracy}] (xmax);
\draw[-latex,line width=0.75pt] (0,0)--(0,7) coordinate[label={below left:$\$$}] (ymax);
\draw[line width=0.5pt] (0,0)--(0,-0.1)node[below]{0};
\draw[line width=0.5pt] (0,0)--(-0.10,0)node[left]{0};
\draw[red,line width=0.5pt,name path=MC]    (1,1) --(6,4)node[right] {$\rm MC$} ;
\draw[ggreen,line width=0.5pt,name path=MB](1,4)--(6,1)node[right] {$\rm MB$};
\path [name intersections={of=MB and MC,by=A}];
\draw[dotted,black!70,line width=0.5pt] (A)--(A|-xmax)node[below]{};
 \draw[line width=0.5pt] (A|-xmax)--++(0,-0.1)node[below]{$q_0$};
\end{tikzpicture} 

\end{document}

我得到了下面的图片

在此处输入图片描述

我需要一个解决方案来延长这两条线(B 和 MC)应该“继续向左”但停止在 y 轴,正如我在下图中指出的那样

在此处输入图片描述

如果有人能帮助我,我将不胜感激。

答案1

您正在加载交叉点,但是对于此任务,您甚至不需要它们。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}

\begin{tikzpicture}[scale=1.0]
\definecolor{ggreen}{cmyk}{1,0.2,1,0.2}
\draw[font={\fontsize{9pt}{9}\selectfont},-latex,line width=0.75pt] (0,0)--(8,0) coordinate[pos=0.9,label={below:Accuracy}] (xmax);
\draw[-latex,line width=0.75pt] (0,0)coordinate (O)--(0,7)coordinate(Y) coordinate[label={below left:$\$$}] (ymax);
\draw[line width=0.5pt] (0,0)--(0,-0.1)node[below]{0};
\draw[line width=0.5pt] (0,0)--(-0.10,0)node[left]{0};
\draw[red,line width=0.5pt,name path=MC]    (1,1) coordinate (MC-1) --(6,4)
coordinate (MC-2) node[right] {$\rm MC$} ;
\draw[red,line width=0.5pt] (intersection cs:first line={(MC-1)--(MC-2)}, 
second line={(O)--(Y)}) -- (MC-1);
\draw[ggreen,line width=0.5pt,name path=MB](1,4) coordinate (MB-1)
--(6,1) coordinate (MB-2) node[right] {$\rm MB$};
\draw[ggreen,line width=0.5pt] (intersection cs:first line={(MB-1)--(MB-2)}, 
second line={(O)--(Y)}) -- (MB-1);
\path [name intersections={of=MB and MC,by=A}];
\draw[dotted,black!70,line width=0.5pt] (A)--(A|-xmax)node[below]{};
 \draw[line width=0.5pt] (A|-xmax)--++(0,-0.1)node[below]{$q_0$};
\end{tikzpicture} 

\end{document}

在此处输入图片描述

相关内容