Please consider the following :
covMatrice = {{34.925, -10.21}, {-10.21, 22.462}};
COG = Mean@(Nfixations["d"][[1]])[[All, 1]];
fixations = {{19.4688, 17.4281}, {18.0563, 21.7156}, {13.0219, 24.7219},
{22.9594,25.5219}, {28.5406, 24.6719}, {27.0688, 17.1656},
{27.6781,16.325}, {28.9281, 10.7719}, {16.025, 13.6625},
{19.1313, 17.1094}};
With[{
eigVec = Eigenvectors[covMatrice],
eigVal = Eigenvalues[covMatrice]},
Graphics[{
White, Rectangle @@ frmXY,
Black, Disk[#, .5] & /@ fixations,
Red, Line[(# + COG) & /@
{eigVec[[1]]*eigVal[[1]]/5,
{0, 0},
eigVec[[2]]*eigVal[[2]]/5}]}]]
How could I draw an ellipse representing on the EigenSystem given that Neither Disk or Circle enable to implement an "orientation" ?
A rough example of my desired output as drawn using PPT :
Answer
You can use Rotate
to draw the ellipse too. Note that knowing the eigenvectors is the same as knowing the orientation of the ellipse, so there is no necessity to favour GeometricTransformation
over Rotate
. So, to orient your ellipse along the first eigenvector (corresponding to the largest eigenvalue), it is as simple as:
Graphics[Rotate[Disk[meanVec, eigVals], ArcTan @@ eigVecs[[1]]]]
where meanVec
is the mean (here, I've taken it to be {0,0}
)
Going by your comment under rcollyer's answer, here's a example reproducing your desired figure with simple shifting (change the center of the disk) and rotation of the disk. This approach will be simpler to follow (as the transformations are spelled out), if you do not understand what GeometricTransformation
does. Modifying rcollyer's module,
Module[{mat = #, avg = Mean@fixations, eigVals, eigVecs},
{eigVals, eigVecs} = Eigensystem@mat;
Graphics[{{Black, Disk[#, .5] & /@ fixations},
{Directive[Opacity[0.1], Red, EdgeForm[Gray]],
Rotate[Disk[avg, eigVals/5], ArcTan @@ eigVecs[[1]]]}
}]
]&@covMatrice
Comments
Post a Comment