Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose I define

f[x] := Piecewise[{{1.7*10^-6, 150 <= x <= 200}}, 0]

and then plot

Plot[Evaluate[f[x]], {x, 0, 1000}, PlotStyle -> {Red, Thick},
     ExclusionsStyle -> {Dashed, Red}]

I get an interrupted dashed vertical line on left

Plot of Piecewise function with Exclusion dashed line missing

Anyone know why this happens and how to draw the entire dashed line?

share|improve this question
Just increase your PlotPoints e.g. PlotPoints->100. – Spawn1701D Apr 18 '13 at 21:02
@Spawn1701D Cheers! Can you provide this as an answer so I can accept it? – Name Apr 18 '13 at 21:40
Very trivial to worth an answer. If you want just upvote the comment instead. Cheers! – Spawn1701D Apr 18 '13 at 21:45
up vote 1 down vote accepted

Mathematica's plot algorithms are not optimized when values become very large or in your case very small. You could include your plot in a Manipulate to see the behavior when you adjust e.g. PlotPoints

f[x_] := Piecewise[{{1.7*10^-6, 150 <= x <= 200}}, 0];
 Plot[Evaluate[g[x]], {x, 0, 1000}, PlotStyle -> None, 
  ExclusionsStyle -> {Dashed, Red}, PlotPoints -> n, 
  PerformanceGoal -> "Quality", Mesh -> All],
 {n, 20, 100, 1}]

enter image description here

And now you could replace your function f with an equivalent function g which returns 1 and not the very small number. Then you'll see the the plot behaves much better with different settings for PlotPoints

g[x_] := Piecewise[{{1, 150 <= x <= 200}}, 0]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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