如何使用 tikzpicture 修复这个笛卡尔平面?

如何使用 tikzpicture 修复这个笛卡尔平面?

我想修改这个笛卡尔平面,通过绘制垂直线 x = -2 并添加 0 和图中所示的线条,但我无法修复它们。您能帮帮我吗?

在此处输入图片描述

\documentclass[margin=20pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots} %%%%%



     \usepackage{lxfonts}

\begin{document}
\begin{tikzpicture}[
  dot/.style={
    circle,fill,draw,minimum size=2mm,inner sep=0
  }]



\begin{axis}[
    axis equal image,
    max space between ticks=20, % This is one way of getting a tick for every integer
    ticklabel style={font=\scriptsize},
    axis lines = middle,
    xmin=-5.5, xmax=5.5, % The range over which the x axis is drawn
    ymin=-4.5, ymax=6.0, % The range over which the y axis is drawn
    domain=-6:5.5,         % The range over which the function is evaluated
    grid=both, 
    xlabel=$x$, ylabel=$y$     
]



 \addplot [very thick, blue, smooth] {-(0)*x+1};

\coordinate [label=above right:$0$] t (0.0,0.0);
\draw [color=black,fill=black,fill opacity=1.0] (a) circle (0.15cm);



 \coordinate [label=above right:$y=1$] at (-4.0,2.0);


  \coordinate [label=above right:$x=-2$] at (-4.0,-3.0);

\end{axis}



\end{tikzpicture}



\end{document}

在此处输入图片描述

在此处输入图片描述

答案1

我添加了一个建议(并修复了一些小错误)。

\documentclass[margin=20pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{pgfplots} %%%%%
\pgfplotsset{compat=1.16}
%\usepackage{lxfonts}

\begin{document}
\begin{tikzpicture}[
  dot/.style={
    circle,fill,draw,minimum size=2mm,inner sep=0
  }]



\begin{axis}[
    axis equal image,
    max space between ticks=20, % This is one way of getting a tick for every integer
    ticklabel style={font=\scriptsize},
    axis lines = middle,
    xmin=-5.5, xmax=5.5, % The range over which the x axis is drawn
    ymin=-4.5, ymax=6.0, % The range over which the y axis is drawn
    domain=-6:5.5,         % The range over which the function is evaluated
    grid=both, 
    xlabel=$x$, ylabel=$y$     
]



 \addplot [very thick, blue] {-(0)*x+1} node[above left,font=\small]{$y=1$};
 \addplot [very thick, red,domain=6:-3.5] (-2,{x}) node[below,font=\small]{$x=-2$};
 \node[dot,label={[font=\small]above right:$0$}] (a) at (0,0){};

\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容