2
$\begingroup$

I use ListLinePlot to plot data:

data = {1.76703857907629*10^-05, 4.81140563002228*10^-05, 
0.000289014453115104, 0.00197771091043209, 0.0110423194539717, 
0.0498810246783513, 0.190154244971562, 0.627874813716429, 
1.80989253153018, 4.54933071011039, 9.93984896528626, 
18.8366788617287, 30.9406437229311, 44.0665972030142, 
54.4589381973665, 58.4368628024863, 54.4589381973665, 
44.0665972030142, 30.9406437229311, 18.8366788617287, 
9.93984896528626, 4.54933071011039, 1.80989253153018, 
0.627874813716429, 0.190154244971562, 0.0498810246783513, 
0.0110423194539717, 0.00197771091043209, 0.000289014453115104, 
4.81140563002228*10^-05, 1.76703857907629*10^-05}
x1=ListLinePlot[data]
x2=ListLinePlot[data, Filling -> Axis]

But now I only want to fill the data from x=10 to x=20. I didn't find anything liek partial filling depending on the x-axis in the documentary or here at mathematica.SE.

Is there a simple solution or do I have to play with partial plots, which I combine with Show?

$\endgroup$
3
  • $\begingroup$ You can overlay two plots. Make one unfilled plot with all the data, one filled plot with a subset of your data, and combine with Show[]. $\endgroup$ Jul 3, 2015 at 10:49
  • $\begingroup$ @Guesswhoitis. ok thanks. that was one option which i thought might work. good to have a confirmation that there is no simpler way. thanks! $\endgroup$ Jul 3, 2015 at 10:57
  • $\begingroup$ There might be a simpler way I'm missing; I just threw out one of the things that could be tried in this situation. $\endgroup$ Jul 3, 2015 at 11:01

1 Answer 1

3
$\begingroup$
data2 = data; data2[[;; 9]] = Null; data2[[21 ;;]] = Null;
ListLinePlot[{data, data2}, Filling -> {2 -> Axis}]

Mathematica graphics

Or

data3 = MapIndexed[{First@#2, #} &, data];
data3b = Select[data3, 10 <= #[[1]] <= 20 &];
ListLinePlot[{data3, data3b}, Filling -> {2 -> Axis}]
(* same picture *)
$\endgroup$
2
  • $\begingroup$ Ah the first one is a nice solution. I expected that one could do it somehow like that. And I'm surprised that partial filling is not implemented more directly; expected that it might be used quite often. Thanks a lot! $\endgroup$ Jul 3, 2015 at 11:29
  • 1
    $\begingroup$ Oh, and now I learned that Null!=0. That is very important! Thanks :) $\endgroup$ Jul 4, 2015 at 14:27

Your Answer

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

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