Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

Now we can see the problem here: those points where gaps happen are discontinuity points of Floor, but they still belong to the function's domain thus should not be excluded. I would say this can be a flaw (or even a bug) of Plot and would be happy if there were an option say Discontinuity -> .... For people who look for more details about this exclusion vs. discontinuity topic, there is a thread on ita thread on it.

Now we can see the problem here: those points where gaps happen are discontinuity points of Floor, but they still belong to the function's domain thus should not be excluded. I would say this can be a flaw (or even a bug) of Plot and would be happy if there were an option say Discontinuity -> .... For people who look for more details about this exclusion vs. discontinuity topic, there is a thread on it.

Now we can see the problem here: those points where gaps happen are discontinuity points of Floor, but they still belong to the function's domain thus should not be excluded. I would say this can be a flaw (or even a bug) of Plot and would be happy if there were an option say Discontinuity -> .... For people who look for more details about this exclusion vs. discontinuity topic, there is a thread on it.

Source Link
Silvia
  • 27.6k
  • 3
  • 85
  • 166

This answer is mainly about why there are gaps, and why it may not be a bug ( of Graphics).

First take a look at this example:

Row[
    Plot[Floor[x], {x, 1, 3}, Axes -> False, PlotStyle -> None, 
       Filling -> Axis, PlotRange -> {-1, 3}, ImageSize -> 201, 
       Exclusions -> #] & /@ {True, None}
   ];
Column[{%, % /. Polygon[pts__] :> {EdgeForm[Black], FaceForm[], Polygon[pts]}}]

plots with and without Exclusions

It seems an exclusion point will force Plot using seperate Polygons, while Exclusions -> None makes it using a single one. That is why @Pickett 's method works.

Now take a look at the FullForm of the plot with gap, it can be seen that the right most points of the left Polygon have a x-coordinate 1.999362244897959` , which is slightly smaller than that of the left most points of the right Polygon 2.0006377551020407` . So I would say this is a "real" gap (possible deliberately introduced by Exclusions -> True to indicate the (neighbourhood of the) exclusion point) for a (most-of-the-time) good purpose.

To eliminate the gaps, one just need to align the corresponding vertices perfectly. For example:

With[{w = .1, δw = 0.001},
    Graphics[GraphicsComplex[{
                {0, 1}, {0, 0},
                {w, 0}, {w, 1},
                {w + δw, 1}, {w + δw, 0},
                {2 w, 0}, {2 w, 1}
                },
            {
                EdgeForm[],
                FaceForm[RGBColor[0.368417`, 0.506779`, 0.709798`]],
                Polygon[{{1, 2, 3, 4}}], Polygon[{{5, 6, 7, 8}}]
                }
            ]]
    ]

If δw is set to 0, even there are still two Polygons, there won't be any visible gap under any ImageSize. (Tested in MMA 9.0.1 and 10.0.1 on Windows 8.1.)

Now we can see the problem here: those points where gaps happen are discontinuity points of Floor, but they still belong to the function's domain thus should not be excluded. I would say this can be a flaw (or even a bug) of Plot and would be happy if there were an option say Discontinuity -> .... For people who look for more details about this exclusion vs. discontinuity topic, there is a thread on it.