I know that there are plenty of posts on this, but I just cannot find the right one that solves my issue. The issue is that I have two datasets that I plot them using ListLinePlot
. I would like to fill the area enclosed by them with different colors (use Green when A is on B and use Yellow when B is on A). But this simple issue turns out to be challenging. No matter how I play around with the command Filling
the color that it uses for the areas is always the same (see the photo). I know that one way is to find the intersection point and then regenrate the data but I don't want to mess with that. I believe there should be an easy workaround for this.
And secondly, how to calculate the two areas separately?
Here is the code:
test1 = {{0.01, 21.96}, {0.19, 22.06}, {0.36, 22.06}, {0.54,
22.06}, {0.71, 22.06}, {0.89, 22.06}, {1.06, 22.05}, {1.24,
22.05}, {1.41, 22.06}, {1.59, 22.05}, {1.76, 22.05}, {1.94,
22.05}, {2.11, 22.05}, {2.29, 22.05}, {2.46, 22.06}, {2.64,
22.04}, {2.81, 22.03}, {2.99, 21.96}, {3.16, 21.79}, {3.34,
20.56}, {3.51, 16.5}, {3.69, 11.71}, {3.86, 7.62}, {4.04,
4.52}, {4.21, 3.19}, {4.39, 2.99}, {4.56, 2.95}, {4.74,
2.95}, {4.91, 2.95}, {5.09, 2.95}, {5.26, 2.96}, {5.44,
2.96}, {5.61, 2.96}, {5.79, 2.96}, {5.96, 2.96}, {6.14, 2.96}};
test2 = {{0.02, 22.16}, {0.08, 22.14}, {0.16, 22.07}, {0.22,
22.07}, {0.29, 22.07}, {0.36, 22.07}, {0.44, 22.06}, {0.5,
22.06}, {0.58, 22.06}, {0.64, 22.06}, {0.72, 22.06}, {0.78,
22.06}, {0.86, 22.06}, {0.92, 22.06}, {1., 22.06}, {1.06,
22.06}, {1.14, 22.06}, {1.2, 22.06}, {1.27, 22.06}, {1.34,
22.06}, {1.41, 22.06}, {1.48, 22.06}, {1.56, 22.06}, {1.62,
22.06}, {1.69, 22.06}, {1.76, 22.06}, {1.84, 22.06}, {1.9, 22.06},
{1.97, 22.06}, {2.04, 22.06}, {2.11, 22.06}, {2.18, 22.06}, {2.25,
22.06}, {2.32, 22.06}, {2.4, 22.06}, {2.46, 22.06}, {2.54,
22.06}, {2.6, 22.06}, {2.68, 22.06}, {2.74, 22.05}, {2.82,
22.05}, {2.88, 22.04}, {2.96, 22.02}, {3.02, 22.}, {3.09,
21.97}, {3.16, 21.92}, {3.24, 21.83}, {3.3, 21.73}, {3.38,
21.59}, {3.44, 21.34}, {3.52, 20.82}, {3.58, 17.72}, {3.66,
12.82}, {3.72, 9.42}, {3.8, 6.91}, {3.86, 5.12}, {3.94,
4.05}, {4., 3.51}, {4.08, 3.25}, {4.14, 3.13}, {4.22,
3.06}, {4.28, 3.02}, {4.36, 3.}, {4.42, 2.99}, {4.5, 2.99}, {4.57,
2.99}, {4.63, 2.99}, {4.7, 2.99}, {4.78, 2.99}, {4.84,
2.99}, {4.92, 2.99}, {4.98, 2.99}, {5.05, 2.99}, {5.12,
2.99}, {5.2, 2.99}, {5.26, 2.99}, {5.34, 2.99}, {5.4,
2.99}, {5.48, 2.99}, {5.54, 2.99}, {5.62, 2.99}, {5.68,
2.99}, {5.76, 2.99}, {5.82, 2.99}, {5.9, 2.99}, {5.96,
2.99}, {6.04, 2.99}, {6.1, 2.99}, {6.18, 2.99}, {6.24, 2.99}};
ListLinePlot[{test1, test2}, Filling -> {1 -> {{2}, {Yellow, Green}}}]
Thanks
Filling
commands seem to work for me , I think I put them in exactly as you have them? Sorry that I don't really know how to identify what is causing theFilling
behavior here $\endgroup$