Videos
What is the floor function example?
How do you write a floor function?
What does floor function do?
The graph is a little misleading. It only includes the "flat" parts, not the "diagonal" segments connecting them.
The complete graph is the union of the horizontal half-open segments
$$\left(\bigcup_{n\in\mathbb{N}}[n^2,n^2+n)\times\{n\}\right)\cup\left(\bigcup_{n\in\mathbb{N}}(n^2-n,n^2]\times\{-n\}\right)$$
The first union comprises segments above the x-axis, and the second comprises those below the x-axis. As you move to the right, each segment is one unit longer and one unit higher (lower, for segments below the x-axis) than the previous segment. There is a longer and longer gap between segments. Ignore the diagonal "connectors" in your graph and it is right.
floor(x/y) is the integer $n$ satisfying:
$$n \le \frac{x}{y} < n + 1$$
If $n = y$, then:
$$y \le \frac{x}{y} < y + 1$$
If $y > 0$, then:
$$y^2 \le x < y^2 + y$$ $$\frac{-1 + \sqrt{1+4x}}{2} < y \le \sqrt{x}$$
If $y < 0$, then:
$$y^2 \ge x > y^2 + y$$ $$y^2 + y < x \le y^2$$ $$-\sqrt{x} \le y < \frac{-1 - \sqrt{1+4x}}{2}$$
So, you get a graph that's similar to $y = \pm \sqrt{x}$ (with both positive and negative branches), except that $y$ takes on only nonzero integer values.
You can use the jump mark mid style for this, which draws horizontal unconnected line segments.
\begin{tikzpicture}
\begin{axis}[axis lines=middle]
\addplot [
jump mark mid,
domain=-3:3,
samples=100,
very thick, red
] {floor(3*x)+2};
\end{axis}
\end{tikzpicture}
to get

A fancier approach could be to use the discontinuous style from the question Probability density function of Uniform Distribution to plot the intervals.
Two small refinements to Jake's solution:
The start and end line have only half of the line width as the other lines because of
pgfplot's clipping of the plot area. This can be fixed by either disable clippingclip=falseor enlarging the plot are in the vertical directions:enlarge y limits={abs=.6pt}(very thickis 1.2pt).The more serious issue is that the start and end points of the lines are not correct, after adding option
grid:
The sample points left and right of a jump value do not have the same distance, for example at x = 1.
There are two ways of fixing it:
The first way works by accident only:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle, grid, clip=false]
\addplot [
jump mark right,
mark=*,
domain=-3:3,
samples=19,
very thick, red
] {floor(3*x)+2};
\end{axis}
\end{tikzpicture}
\end{document}
The sample points are marked. The number of samples is the number of lines plus one for an additional end point:
It works only, because x values for the sample points except the first are a tiny bit (rounding error) too small.
A more stable solution is to use the middle points of the lines. Unhappily it complicates the domain and plot area options. Version with grid and marked sample points and without clipping:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
grid,
clip=false,
xmin=-3,
xmax=3,
ymin=-7,
ymax=10,
enlarge y limits={abs=.6pt}, % very thick: 1.2pt
]
\addplot [
jump mark mid,
mark=*,
domain=-3 - 1/6:3 + 1/6,
samples=20,
very thick, red
] {floor(3*x)+2};
\end{axis}
\end{tikzpicture}
\end{document}
And the final solution:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
xmin=-3,
xmax=3,
ymin=-7,
ymax=10,
enlarge y limits={abs=.6pt}, % very thick: 1.2pt
]
\addplot [
jump mark mid,
domain=-3 - 1/6:3 + 1/6,
samples=20,
very thick, red
] {floor(3*x)+2};
\end{axis}
\end{tikzpicture}
\end{document}


