Drawing a second set of coordinate axes on the same plot

What is the right way to visualize a second set of "rotated" coordinate axes on a plot? As an example, for the diagram below, I want to show the choice of coordinate system which makes the distribution centered at 0 with diagonal covariance matrix. How should I draw this? I tried Show[a,Rotate[a]] but get "Could not combine the graphics objects"

sigma = {{1, 0}, {0, 1/10}};
rot = RotationMatrix[Pi/4];
dist = MultinormalDistribution[{2, 2}, rot.sigma.rot\[Transpose]];
a = ListPlot[RandomVariate[dist, 10000],
PlotRange -> {{-5, 5}, {-5, 5}}, AspectRatio -> 1] You can use the new in M12.3 AxisObject to do this. For example:

sigma = {{1, 0}, {0, 1/10}};
rot = RotationMatrix[Pi/4];
dist = MultinormalDistribution[{2,2}, rot . sigma . rot\[Transpose]];
a = ListPlot[
RandomVariate[dist,10000],
PlotRange->{{-5,5},{-5,5}},
AspectRatio->1,
Epilog->{
AxisObject[Line[{{0, 0}, {4, 4}}], {-1, 1}],
AxisObject[Line[{{0, 4}, {4, 0}}], {-1, 1}]
}
] • Woah - I need to upgrade! Jul 14 '21 at 11:07

Here's one manual approach using Overlay. You will need to fine tune the size of the 2nd axis to align more generally.

data = RandomVariate[dist, 10000];
b = ListPlot[data, PlotRange -> {{-5, 5}, {-5, 5}}, AspectRatio -> 1];
Manipulate[
Overlay[{b, Rotate[ListPlot[{}, AspectRatio -> 1], theta Degree]},
Alignment -> {x, y}],
{{theta, 0}, 0, 360},
{{x, 0}, -1, 1},
{{y, 0}, -1, 1}] update 1

If the real data are as simple as the sample set, the following code gets the angle right and is close to getting the origin correct.

b = ListPlot[data, PlotRange -> {{-5, 5}, {-5, 5}}, AspectRatio -> 1];
c = ListPlot[{}, AspectRatio -> 1];
Overlay[{b,
Rotate[c, VectorAngle[{1, 0}, First@Eigenvectors@Covariance@data]]},
Alignment -> 