LaTeX 中的 $0.5(floor(x)+x $ 图表

LaTeX 中的 $0.5(floor(x)+x $ 图表

如何$0.5(floor(x)+x $在 LaTeX 中绘制图形。使用 GeoGebra 命令时,无法在 Latex 中映射形状。

\begin{tikzpicture}
%\draw [line width=0.3pt,pink](-3,-4) grid (3,4);
\begin{axis}[axis lines=middle]
\addplot [
    jump mark mid,
    domain=-3:3,
    samples=600,
    very thick, red
] {((0.5)*floor(x))+x};
\draw [color=blue] (1,-2) circle (3pt);
\end{axis}
\end{tikzpicture}

答案1

为了好玩,很简单pstricks

\documentclass[11pt,svgnames, border=3pt]{standalone}
\usepackage{pst-plot, multido}

\begin{document}

\begin{pspicture*}(-1,-1)(5,5)
\multido{\i=1+1,\n=0.5+1.0}{5}{\psline[linestyle=dotted, dotsep=2pt, linecolor=LightSteelBlue](\i, \n)(0,\n)}
\psaxes[ticksize=2pt, ysubticks=2, labelFontSize=\scriptstyle\color{SteelBlue}, showorigin=false, arrows=->,arrowinset=0.12, linecolor=SteelBlue](0,0)(-0.99,-0.99)(5,5)[$x$, -120][$y$,-135]
\uput[dl](0,0){$ O $}
\psset{linewidth=1pt,linecolor=IndianRed,algebraic, plotpoints=40, dash=2pt 1.5pt}
\multido{\i=0+1}{5}{\psCoordinates[linewidth=0.4pt, linecolor=LightSteelBlue, linestyle= dashed, markPoint=false](\i, \i)%
\psplot[dotsize=2pt, arrows=*-]{\i}{\i.99}{0.5*(floor(x) + x)}}%
\end{pspicture*} 

\end{document} 

在此处输入图片描述

答案2

在这种情况下,我的选择是普通的 tikz:

\documentclass[border=2mm]{standalone}
\usepackage   {tikz}

\begin{document}
\begin{tikzpicture}[line cap=round]
\def\minx{-2}
\def\maxx {5}
\pgfmathtruncatemacro\maxi{\maxx-1}
\useasboundingbox (\minx-0.5,\minx-0.5) rectangle (\maxx+0.5,\maxx+0.5);
\draw[thin,gray!50] (\minx,\minx) grid (\maxx,\maxx);
\draw[thick,-latex] (\minx,0) -- (\maxx,0) node[right] {$x$};
\draw[thick,-latex] (0,\minx) -- (0,\maxx) node[above] {$y$};
\foreach\i in {\minx,...,\maxi}
{
  \draw[thick,red]      (\i,\i) --    (\i+1,\i+0.5);
  \fill[red]            (\i,\i)       circle (0.05);
  \draw[red,fill=white] (\i+1,\i+0.5) circle (0.05);
}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容