# How to create a graph for Gaussian brackets in LaTeX

I'm just getting started in LaTeX and have never created a plot there (only have some experience of plotting in R). Now my task is to create a graph for f(x) = x-[x] wherein [] is a Gaussian bracket which means [x] is the greatest integer not exceeding x. How would I go about creating that plot in LaTeX? Thanks for an answer in advance. (I already know what the graph has to look like on paper). Btw. I'm using Texmaker.

• You can use the pgfmath function floor() or \pgfmathflloor and \pgfmathresult. Plots are usually done using pgfplots, but can be done with tikz visualization. – John Kormylo May 4 at 14:08
• \documentclass[tikz,border=3.14mm]{standalone} \begin{document} \begin{tikzpicture} \draw[thick,-stealth] (-4.2,0) -- (5.2,0); \draw[thick,-stealth] (0,-0.2) -- (0,1.8); \foreach \X in {-4,-3,...,4} {\draw[blue] (\X,0) node[circle,inner sep=1pt,fill,draw,label={[black]below:\X}]{} -- ++ (1,1)node[circle,inner sep=1pt,draw,fill=white]{};} \end{tikzpicture} \end{document} – user121799 May 4 at 15:51

Here is a very short code with pstricks:

\documentclass[border =6pt, svgnames]{standalone}
\usepackage{auto-pst-pdf}

\begin{document}

\psset{unit=15mm, algebraic, arrows=*-o, showorigin=false}
\begin{pspicture}*(-3.6,-1.6)(4,2)
\psaxes[linecolor=LightSteelBlue, tickcolor=LightSteelBlue]{->}(0,0)(-3.9,-1.9)(4,2)[$x$,-120][ $y$,-130]
\multido{\i =-4 + 1}{8}{\psplot[linecolor=IndianRed]{\i}{\pscalculate{\i+0.99}}{x-floor(x)}}
\end{pspicture}

\end{document}


• Thank you so much, I had already tried my luck with pgfplots but couldn't get the result to look like yours. Again, thanks. – psyph May 5 at 19:09