# Unexpected Behaviour at Plotting Floor with Plot [duplicate]

I wanted to plot a function involving Floor, here is my code:

epsilon = 0.1;
f[t_] = Floor[t/epsilon];
Plot[{f[t]}, {t, 0, 5}]


it gives me the following, which has smaller bars as t increases:

I know that I can plot Floor with DiscretePlot, as suggested here, but I would like to understand, why Plot cannot handle it correctly. Thanks!

• Related: (29346) Apr 15, 2015 at 16:07

You need to specify more PlotPoints

epsilon = 0.1;
f[t_] = Floor[t/epsilon];

Plot[{f[t]}, {t, 0, 5},
PlotPoints -> 250,
ImageSize -> 500]


epsilon = 0.5;
f[t_] = Floor[t/epsilon];

Plot[{f[t]}, {t, 0, 5},
ColorFunction -> "Rainbow",
PlotPoints -> 250,
PlotStyle -> Thickness[0.01],
PlotTheme -> "Detailed",
ImageSize -> 500]


epsilon = 0.5;
f[t_] = Floor[t/epsilon];

Plot[{f[t]}, {t, 0, 5},
Filling -> Axis,
Frame -> True,
FrameTicks -> {{All, None}, {Range[0, 5, 0.5], None}},
GridLines -> {Range[0, 5, 0.5], Range[0, 10, 1]},
PlotPoints -> 250,
PlotStyle -> Thickness[0.001],
ImageSize -> 500]


• thanks, that solves the problem. but do you have an intuitive understanding why mathematica decides to make the bars smaller? So, why does it work better for small t as for large t? Oct 5, 2014 at 16:57
• @NicoDean I don't understand it either. With too few PlotPoints you just get unpredictable results. I don't even see a pattern "within" this unpredictability.
– eldo
Oct 5, 2014 at 17:13
• The bar length is determined by where the adaptive sampling for Plot selects the plot points. This is affected by the initial sampling points set by the option PlotPoints. Oct 5, 2014 at 19:26