4
$\begingroup$

Would someone mind showing me how to plot a floor function with the appropriate endpoints? I tried Google, but the best I could find was something posted from 2004 that no longer appears to work.

Sorry if this is overly basic, I've only got a couple of weeks of experience with Mathematica and no one to work with on it.

Edit: I'm looking to create a graph similar to the one shown on the wiki page for floor/ceiling functions. I'm not too concerned with the frame or the tick marks.

$\endgroup$
1
  • 2
    $\begingroup$ You just need to add Exclusions -> None to your plot command. Also, the documentation covers this very example $\endgroup$
    – rm -rf
    Sep 26, 2012 at 0:40

2 Answers 2

9
$\begingroup$

To plot $\lfloor x\rfloor$ you can use DiscretePlot at the integers with ExtentSize and ExtentMarkers:

DiscretePlot[Floor[x], {x, 0, 8}, ExtentSize -> Right, 
 ExtentMarkers -> {"Filled", "Empty"}, Filling -> None]

enter image description here

$\endgroup$
2
  • $\begingroup$ Sadly this doesn't work on v7, which explains why I haven't used these options before. :-/ $\endgroup$
    – Mr.Wizard
    Sep 26, 2012 at 2:58
  • $\begingroup$ @Mr.Wizard Yes, the Extent* options were added in V8. $\endgroup$ Sep 26, 2012 at 3:07
2
$\begingroup$

From the help:

Plot[Floor[x], {x, 0, 10}, ExclusionsStyle -> {Red, Blue}]

Mathematica graphics

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.