我正在从 GeoGebra 导出代码以在乳胶中绘制地板函数,但它不起作用(地板函数)

我正在从 GeoGebra 导出代码以在乳胶中绘制地板函数,但它不起作用(地板函数)

再会!

我已经将此代码(用于制作 floor 函数图)从 GeoGebra 转移到 LaTeX,但输出非常奇怪,没有得到与我在 GeoGebra 中获得的相同的输出。请帮忙。

以下是代码:

\definecolor{xdxdff}{rgb}{0.49019607843137253,0.49019607843137253,1}
\definecolor{qqwuqq}{rgb}{0,0.39215686274509803,0}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\begin{axis}[
x=1cm,y=1cm,
axis lines=middle,
ymajorgrids=true,
xmajorgrids=true,
xmin=-15.16,
xmax=15.16,
ymin=-11.76,
ymax=7.2,
xtick={-15,-14,...,15},
ytick={-11,-10,...,7},]
\clip(-15.16,-11.76) rectangle (15.16,7.2);
\draw[line width=2pt,color=qqwuqq,smooth,samples=100,domain=-15.16:15.16] plot(\x,{floor((\x))});
\begin{scriptsize}
\draw[color=qqwuqq] (-10.72,-11.43) node {$f$};
\draw [fill=xdxdff] (1,1) circle (2.5pt);
\draw[color=xdxdff] (1.16,1.43) node {$A$};
\draw [fill=xdxdff] (2,2) circle (2.5pt);
\draw[color=xdxdff] (2.16,2.43) node {$B$};
\draw [fill=xdxdff] (3,3) circle (2.5pt);
\draw[color=xdxdff] (3.16,3.43) node {$C$};
\draw [fill=xdxdff] (4,4) circle (2.5pt);
\draw[color=xdxdff] (4.16,4.43) node {$D$};
\draw [fill=xdxdff] (0,0) circle (2.5pt);
\draw[color=xdxdff] (0.16,0.43) node {$E$};
\draw [fill=xdxdff] (-2,-2) circle (2.5pt);
\draw[color=xdxdff] (-1.84,-1.57) node {$F$};
\draw [fill=xdxdff] (-3,-3) circle (2.5pt);
\draw[color=xdxdff] (-2.84,-2.57) node {$G$};
\draw [fill=xdxdff] (-1,-1) circle (2.5pt);
\draw[color=xdxdff] (-0.84,-0.57) node {$H$};
\draw [fill=xdxdff] (-4,-4) circle (2.5pt);
\draw[color=xdxdff] (-3.84,-3.57) node {$I$};
\end{scriptsize}
\end{axis}
\end{tikzpicture}

答案1

与往常一样,GeoGebra 生成的代码需要进行编辑。

从 -15 到 15 的范围将导致图形宽度为 30 厘米,因此有必要将其减小。

您还需要指定兼容性级别pgfplots以及超过 100 个的样本。

\documentclass{article}
\usepackage{tikz,pgfplots}
\usetikzlibrary{arrows,arrows.meta}
\pgfplotsset{compat=1.17}

\begin{document}

\definecolor{xdxdff}{rgb}{0.5,0.5,1}
\definecolor{qqwuqq}{rgb}{0,0.4,0}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,font=\scriptsize]
\begin{axis}[
  x=1cm,y=1cm,
  axis lines=middle,
  ymajorgrids=true,
  xmajorgrids=true,
  xmin=-5.16,
  xmax=5.16,
  ymin=-5.76,
  ymax=5.2,
xtick={-5,-4,...,5},
ytick={-6,-5,...,6},
]
\draw[
  line width=1pt,
  color=qqwuqq,
  smooth,
  samples=1000, % 100 is too small
  domain=-5.16:5.16] plot(\x,{floor((\x))});
\draw[color=qqwuqq] (-10.72,-11.43) node {$f$};
\draw [fill=xdxdff] (1,1) circle (2.5pt);
\draw[color=xdxdff] (1.16,1.43) node {$A$};
\draw [fill=xdxdff] (2,2) circle (2.5pt);
\draw[color=xdxdff] (2.16,2.43) node {$B$};
\draw [fill=xdxdff] (3,3) circle (2.5pt);
\draw[color=xdxdff] (3.16,3.43) node {$C$};
\draw [fill=xdxdff] (4,4) circle (2.5pt);
\draw[color=xdxdff] (4.16,4.43) node {$D$};
\draw [fill=xdxdff] (0,0) circle (2.5pt);
\draw[color=xdxdff] (0.16,0.43) node {$E$};
\draw [fill=xdxdff] (-2,-2) circle (2.5pt);
\draw[color=xdxdff] (-1.84,-1.57) node {$F$};
\draw [fill=xdxdff] (-3,-3) circle (2.5pt);
\draw[color=xdxdff] (-2.84,-2.57) node {$G$};
\draw [fill=xdxdff] (-1,-1) circle (2.5pt);
\draw[color=xdxdff] (-0.84,-0.57) node {$H$};
\draw [fill=xdxdff] (-4,-4) circle (2.5pt);
\draw[color=xdxdff] (-3.84,-3.57) node {$I$};
\end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容