在一个 tikzpicture 框中绘制两条线

在一个 tikzpicture 框中绘制两条线

你好我想画这个:

在此处输入图片描述

(字母和具体尺寸不重要)

我的代码是这样的,但它不起作用我想在这里混合这两行。

\subfigure
{
\begin{tikzpicture}[smooth,scale=0.8]
\draw[thick,->] (-2,0) -- (2,0) node[below] {$x$};
    \draw[thick,->] (0,-1.5) -- (0,1.5) node[right] {$y$};
    \draw[blue,thick,domain=0:1.5] plot (\x,{\x}) node[above]
    \draw[blue,thick,domain=-1.5:0] plot (\x,{0}) node[above]
\end{tikzpicture}
}
\subfigure

谢谢你的帮助。

答案1

像这样?

在此处输入图片描述

\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document}
    \begin{tikzpicture}[%smooth,scale=0.8
         > = Straight Barb,
dot/.style = {circle, draw, thick, fill=blue, inner sep=2pt,
              label={[fill=white, inner sep=1pt, font=\small]60:#1},
              node contents={},}   
                        ]
% axis                        
\draw[->] (-2.0,0) -- (2,0.0) node[below  left] {$x$};
\draw[->] (0,-1.5) -- (0,1.5) node[below right] {$y$};
%
\draw[very thick]
        (-1.5,0.0) node[dot=A] --
        ( 0.0,0.0) node[dot=B] --
        ( 1.5,1.5) node[dot=C];
    \end{tikzpicture}
\end{document}

相关内容