I'm trying to visually recreate the idea of RSquared between data model from linear regression and my idea was to use ListPlot with data points and model evaluated on the x values of data points and adding the Filling option {1->{2}} keeping in mind that the points in each dataset were sharing the same x coordinates. But the result is not every point filling with its counterpart.
data = List @@@ Table[x -> x + RandomVariate[NormalDistribution[]], {x, RandomReal[{0, 5}, 40]}];
lm = LinearModelFit[data, x, x];
ListPlot[{data, Map[{#, lm[#]} &, data[[All, 1]]]}, Joined -> {False, True}, Filling -> {1 -> {2}}, PlotRange -> All]
Even without the Joined option not all the points shows the filling between the two datasets. Could be this a Mathematica bug? I'm using Mathematica 12.2.0.0 on macOS 11.5.2 Big Sur.
bugs
tag is reserved for questions where the problem has been vetted by this community and the observed behavior is confirmed to be a bug. Please do not use this tag for new questions. $\endgroup$