Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

In a non-joined ListPlot one can specify that a filling line is shown for each point:

ListPlot[Table[{x, Exp[-x^2]}, {x, -2, 2, 0.1}], Filling -> Axis, FillingStyle -> Red]

1

But if the points are out of the plot range, the filling line no longer appears:

ListPlot[Table[{x, Exp[-x^2]}, {x, -2, 2, 0.1}], Filling -> Axis, FillingStyle -> Red, 
  PlotRange -> {0, 0.5}]

2

Is there any way to still show the line up the plot range, to show that there is a point there (but you just can't see it)? Or must I draw the lines myself with a Prolog?

share|improve this question
add comment

1 Answer 1

up vote 13 down vote accepted

One solution is to use ListPlot with PlotRange->All (in your example you don't need it) and crop the region afterwards by calling Show:

gr = ListPlot[Table[{x, Exp[-x^2]}, {x, -2, 2, 0.1}], Filling -> Axis,
    FillingStyle -> Red, PlotRange -> All];
Show[gr, PlotRange -> {Automatic, {0, 0.4}}]
(* or shorter Show[gr, PlotRange -> {0, 0.4}] *)

Mathematica graphics

share|improve this answer
    
Since only the $y$-range is being changed, one could also do the shorter Show[gr, PlotRange -> {0, 0.4}]. –  J. M. Oct 17 '12 at 3:23
    
@J.M. added to the code. Thanks. –  halirutan Oct 17 '12 at 7:57
add comment

Your Answer

 
discard

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.