我表示的是笛卡尔平面和一条抛物线。为什么 A、B、C、D、E 点表示在笛卡尔平面之外?
谢谢你们
这是我的代码:
\documentclass[margin=20pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots} %%%%%
\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=-4.5, xmax=4.5, % The range over which the x axis is drawn
ymin=-4.5, ymax=4.5, % The range over which the y axis is drawn
domain=-4:4, % The range over which the function is evaluated
grid=both,
xlabel=$x$, ylabel=$y$
]
\addplot [very thick, blue, smooth] {x^2+2*x-3};
\end{axis}
%%%POINTS
\node [dot,label=below:\Large$A$] (a) at (-3,0) {};
\node [dot,label=left:\Large$B$] (b) at (-2,-3) {};
\node [dot,label=below:\Large$C$] (c) at (-1,-4) {};
\node [dot,label=right:\Large$D$] (d) at (0,-3) {};
\node [dot,label=right:\Large$E$] (d) at (1,0) {};
\end{tikzpicture}
\end{document}
答案1
下面的代码将曲线上的点叠加在一起。
编辑:我添加了一个带有选项\addplot
的调用,samples at
请参阅pgfmanual
v3.0.1a 第 22.5 节 p328。
\documentclass[margin=20pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots} %%%%%
\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=-4.5, xmax=4.5, % The range over which the x axis is drawn
ymin=-4.5, ymax=4.5, % The range over which the y axis is drawn
domain=-4:4, % The range over which the function is evaluated
grid=both,
xlabel=$x$, ylabel=$y$
]
%Curve
\addplot [very thick, blue, smooth] {x^2+2*x-3};
%Points
\node [dot,label=below:\Large$A$] (a) at (axis cs:-3,0) {};
\node [dot,label=left:\Large$B$] (b) at (axis cs:-2,-3) {};
\node [dot,label=below:\Large$C$] (c) at (axis cs:-1,-4) {};
\node [dot,label=right:\Large$D$] (d) at (axis cs:0,-3) {};
\node [dot,label=right:\Large$E$] (d) at (axis cs:1,0) {};
% Other syntax
\addplot [mark=*,red,draw=none,samples at={-3,-2,-1,0,1}] {x^2+2*x-3};
\end{axis}
\end{tikzpicture}
\end{document}