3
$\begingroup$

I have two lists which are plotted by below simple command

ListPlot[{{{0.`, 0.001`}, {0.05`, 0.04`}, {0.1`, 
0.076`}, {0.15000000000000002`, 0.115`}, {0.2`, 0.151`}, {0.25`, 
0.19`}, {0.30000000000000004`, 0.226`}, {0.35000000000000003`, 
0.265`}, {0.4`, 0.301`}, {0.45`, 0.34`}, {0.5`, 0.376`}, {0.55`, 
0.41500000000000004`}, {0.6000000000000001`, 0.454`}, {0.65`, 
0.49`}, {0.7000000000000001`, 0.529`}, {0.75`, 
0.5650000000000001`}, {0.8`, 0.604`}, {0.8500000000000001`, 
0.64`}, {0.9`, 0.679`}, {0.9500000000000001`, 0.715`}, {1.`, 
0.754`}, {1.05`, 0.79`}, {1.1`, 
0.8290000000000001`}, {1.1500000000000001`, 
0.865`}, {1.2000000000000002`, 0.904`}, {1.25`, 
0.9400000000000001`}, {1.3`, 0.979`}, {1.35`, 
1.015`}, {1.4000000000000001`, 
1.0539999999999998`}, {1.4500000000000002`, 1.093`}, {1.5`, 
1.129`}, {1.55`, 1.168`}, {1.6`, 1.204`}, {1.6500000000000001`, 
1.2429999999999999`}, {1.7000000000000002`, 1.279`}, {1.75`, 
1.3179999999999998`}, {1.8`, 1.3539999999999999`}, {1.85`, 
1.393`}, {1.9000000000000001`, 
1.4289999999999998`}, {1.9500000000000002`, 1.468`}, {2.`, 
1.504`}}, {{0.`, 0.001`}, {0.05`, 0.037000000000000005`}, {0.1`, 
0.07300000000000001`}, {0.15000000000000002`, 0.106`}, {0.2`, 
0.14200000000000002`}, {0.25`, 0.178`}, {0.30000000000000004`, 
0.211`}, {0.35000000000000003`, 0.247`}, {0.4`, 
0.28300000000000003`}, {0.45`, 0.319`}, {0.5`, 
0.35200000000000004`}, {0.55`, 0.388`}, {0.6000000000000001`, 
0.424`}, {0.65`, 0.46`}, {0.7000000000000001`, 0.493`}, {0.75`, 
0.529`}, {0.8`, 0.5650000000000001`}, {0.8500000000000001`, 
0.598`}, {0.9`, 0.634`}, {0.9500000000000001`, 0.67`}, {1.`, 
0.706`}, {1.05`, 0.739`}, {1.1`, 0.775`}, {1.1500000000000001`, 
0.811`}, {1.2000000000000002`, 0.844`}, {1.25`, 0.88`}, {1.3`, 
0.916`}, {1.35`, 0.9520000000000001`}, {1.4000000000000001`, 
0.985`}, {1.4500000000000002`, 1.021`}, {1.5`, 1.057`}, {1.55`, 
1.093`}, {1.6`, 1.126`}, {1.6500000000000001`, 
1.162`}, {1.7000000000000002`, 1.198`}, {1.75`, 
1.2309999999999999`}, {1.8`, 1.267`}, {1.85`, 
1.303`}, {1.9000000000000001`, 1.339`}, {1.9500000000000002`, 
1.3719999999999999`}, {2.`, 1.408`}}}]

I want to have a plot as enter image description here

filling between two list plots drawn by my self. How do I apply filling between any two Listplots?

$\endgroup$
  • 1
    $\begingroup$ Beware filling between discrete data points in ListPlot: (97181) (30145) (G3gob_Mw9sQ). At the very least, make sure the data is sorted (but there can still be issues). $\endgroup$ – Jess Riedel Jun 12 '16 at 21:11
6
$\begingroup$
l1 = Range[30];
l2 = 1.05 Range[30];

Show[ListLinePlot[{l1, l2}, Filling -> {1 -> {2}}, 
  FillingStyle -> Magenta, PlotStyle -> Magenta],
 ListPlot[{l1, l2}]]

enter image description here

ListPlot[{l1, l2}, Mesh -> All, PlotMarkers -> Automatic, 
 Joined -> True, Filling -> {1 -> {2}}, FillingStyle -> Magenta]

enter image description here

Or with very thin lines and all disks.

ListPlot[{l1, l2}, Mesh -> All, 
 PlotMarkers -> {{"●", 10}, {"●", 10}}, 
 Joined -> True, Filling -> {1 -> {2}}, FillingStyle -> Magenta, 
 PlotStyle -> Thickness[0]]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ Thanks a bunch, if possible even short can you tell me about Filling -> {1 -> {2}}, details of its duty. I can't understand mean of that! For example I try with Filling-> True it doesn't satisfy the main aim. $\endgroup$ – Unbelievable Jun 12 '16 at 17:31
  • $\begingroup$ @Irreversible Filling Limits documentation. $\endgroup$ – Karsten 7. Jun 12 '16 at 17:40
3
$\begingroup$
{l1, l2} = {{{0., 0.}, {0.05, 0.04}, {0.1, 0.08}, {0.15, 0.12}, {0.2, 0.15}, {0.25, 0.19}, 
            {0.3, 0.23}, {0.35, 0.26}, {0.4, 0.3}, {0.45, 0.34}, {0.5, 0.38}, 
            {0.55, 0.42}, {0.6, 0.45}, {0.65, 0.49}, {0.7, 0.53}, {0.75, 0.57}, 
            {0.8, 0.6}, {0.85, 0.64}, {0.9, 0.68}, {0.95,  0.72}, {1., 0.75}, 
            {1.05, 0.79}, {1.1, 0.83}, {1.15, 0.86}, 1.2, 0.9}, {1.25, 0.94}, 
            {1.3, 0.98}, {1.35, 1.01}, {1.4, 1.05}, {1.45, 1.09},{1.5, 1.13}, 
            {1.55, 1.17}, {1.6, 1.2}, {1.65, 1.24}, {1.7,   1.28}, {1.75, 1.32},
            {1.8, 1.35}, {1.85, 1.39}, {1.9, 1.43}, {1.95, 1.47}, {2., 1.5}}, 
           {{0., 0.}, {0.05, 0.04}, {0.1, 0.07}, {0.15, 0.11}, {0.2, 0.14},
            {0.25, 0.18}, {0.3, 0.21}, {0.35, 0.25}, {0.4, 0.28}, {0.45, 0.32}, 
            {0.5, 0.35}, {0.55, 0.39}, {0.6, 0.42}, {0.65, 0.46}, {0.7, 0.49}, 
            {0.75, 0.53}, {0.8, 0.57}, {0.85, 0.6}, {0.9, 0.63}, {0.95, 0.67}, 
            {1., 0.71}, {1.05, 0.74}, {1.1, 0.78}, {1.15, 0.81}, {1.2, 0.84}, 
            {1.25, 0.88}, {1.3, 0.92}, {1.35, 0.95}, {1.4, 0.98}, {1.45, 1.02}, 
            {1.5, 1.06}, {1.55, 1.09}, {1.6, 1.13}, {1.65, 1.16}, {1.7, 1.2}, 
            {1.75, 1.23}, {1.8, 1.27}, {1.85, 1.3}, {1.9,  1.34}, 
            {1.95, 1.37}, {2., 1.41}}};

You can repeat the lists and use the option Joined:

ListPlot[{l1, l2, l1, l2}, Joined -> {False, False, True, True} ,
 PlotStyle -> {Red, Blue, None, None}, 
 Filling -> {3 -> {{4}, Yellow}}]

Mathematica graphics

Note (thanks: Karsten7.): to get the default colors for the markers use PlotStyle -> {Automatic, Automatic, None, None}.

$\endgroup$
  • $\begingroup$ PlotStyle -> {Automatic, Automatic, None, None} does create the default plot marker colors. $\endgroup$ – Karsten 7. Jun 12 '16 at 17:47
  • $\begingroup$ @Karsten7., good point, thank you. $\endgroup$ – kglr Jun 12 '16 at 17:49
2
$\begingroup$

If we call the two lists l1 and l2, the thing that looks the most like what you have drawn can be made by turning the lists into InterpolatingFunctions using Interpolation, and then use the plot option Filling:

h1 = Interpolation[l1];
h2 = Interpolation[l2];
Plot[{h1[x], h2[x]}, {x, 0, 2}, Filling -> {1 -> {2}}, FillingStyle -> Magenta]

enter image description here

$\endgroup$
  • $\begingroup$ Your answer is excellent but I have to show the results are related to data not a function. In the final plot points replaced by lines. I have to show exactly by points. $\endgroup$ – Unbelievable Jun 12 '16 at 17:28
2
$\begingroup$

For such data you can also use Prolog:

ListPlot[{l1, l2}, 
 Prolog -> {Yellow, Polygon[Flatten[{l1, Reverse@l2}, 1]]}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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