4
$\begingroup$

I have been struggling with these glitches for two days...

A related question I asked is here How to eliminate the white gaps in the graph

Here is the code,

Show[
  Plot[Sin[x], {x, -2 Pi, 2 Pi}, PlotStyle -> Blue], 
  Plot[Ceiling[Sin[x], 1/3], {x, -2 Pi, 2 Pi}, 
    PlotStyle -> Red, Filling -> Axis, Exclusions -> None], 
  Plot[Floor[Sin[x], 1/3], {x, -2 Pi, 2 Pi}, 
    PlotStyle -> Green, Exclusions -> None, Filling -> Axis], 
  AspectRatio -> 1/Pi, Frame -> False]

and here is the result,

enter image description here

If I remove the "Exclusions -> None" option, there are white gaps.

Show[
  Plot[Sin[x], {x, -2 Pi, 2 Pi}, PlotStyle -> Blue], 
  Plot[Ceiling[Sin[x], 1/3], {x, -2 Pi, 2 Pi}, PlotStyle -> Red, Filling -> Axis], 
  Plot[Floor[Sin[x], 1/3], {x, -2 Pi, 2 Pi}, PlotStyle -> Green , Filling -> Axis], 
  AspectRatio -> 1/Pi, Frame -> False]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ Adding PlotPoints -> 100 for each plot seems to fix the problem, but somehow this is not really a very satisfying approach. $\endgroup$ – Yves Klett Sep 25 '14 at 13:56
  • 4
    $\begingroup$ in any case you really need to work on your MS-Paint-fu :D $\endgroup$ – Yves Klett Sep 25 '14 at 14:28
  • $\begingroup$ You're using two user names. Please ask a moderator to merge both accounts. $\endgroup$ – Dr. belisarius Sep 25 '14 at 14:37
  • 1
    $\begingroup$ Tony, please fill out this developer contact form and request a merge of your accounts. I cannot merge them for you. mathematica.stackexchange.com/contact (Select I need to merge user profiles.) $\endgroup$ – Mr.Wizard Sep 25 '14 at 14:58
  • 1
    $\begingroup$ For this particular case it seem that you can use Exclusions -> 0 without ill effect. $\endgroup$ – Mr.Wizard Sep 25 '14 at 15:02
6
$\begingroup$

This question can be much reduced to reveal the essential problem.

Plot[Ceiling[Sin[x], 1/3], {x, -2 Pi, 2 Pi},
  PlotStyle -> Red, Filling -> Axis, Exclusions -> None]

plot1

The problem is solved by asking for more plot points.

Plot[Ceiling[Sin[x], 1/3], {x, -2 Pi, 2 Pi},
  PlotStyle -> Red, Filling -> Axis, Exclusions -> None, PlotPoints -> 60]

plot2

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.