I want to make a filled Ellipsoid, but it seems Filling options doesn't work in Graphics options. I have a matrix


thus I plot en ellipse from his Eigenvalues and Eigenvectors

valmat = Eigenvalues@matrix1;
vecmat = Eigenvectors@matrix1;
pair = {0.5, 0.5}
ellips1 = 
Ellipsoid[pair, {Abs[valmat[[1]]], Abs[valmat[[2]]]}, {vecmat[[1]], vecmat[[2]]}];
plot1 = Graphics[{Red, ellips1}, GridLines -> Automatic, 
GridLinesStyle -> Directive[Gray, Dotted]];
partot1 = 
Show[plot1, Frame -> True, 
FrameLabel -> {Style["x", 18], Style["y", 18]}, AspectRatio -> 1, 
FrameTicks -> {Automatic, Automatic, None, None}, 
LabelStyle -> Directive[13], ImageSize -> 500]

enter image description here

The question is how to filled this ellipse with an specific color??..and also (if it's possible) the transparency on that. Thanks

  • $\begingroup$ What's Ellipsoid, what pacage is required? $\endgroup$
    – Kuba
    Sep 20 '13 at 13:38
  • $\begingroup$ @Kuba Needs["MultivariateStatistics`"] $\endgroup$
    – ybeltukov
    Sep 20 '13 at 13:38
  • 1
    $\begingroup$ Perhaps use Disk? $\endgroup$ Sep 20 '13 at 13:39
  • $\begingroup$ Use a disk, scale the axis and rotate. $\endgroup$
    – rm -rf
    Sep 20 '13 at 13:40
  • 2
    $\begingroup$ Also, ellipsoid is a graphics, so you need to use faceform/edgeform. See this answer where I use an ellipsoid. $\endgroup$
    – rm -rf
    Sep 20 '13 at 13:42

If there is nothing else:

partot1 /. Line -> Polygon

enter image description here

partot1 /. Line[x_] -> {Green, EdgeForm@Thick, FaceForm[Opacity@.5], Polygon[x]}

enter image description here

Fortunatelly Elipsoid is not ReadProtected so you can use ?? to se the UpValues related to it. (I suggest to Ctrl+F and replace/delete all contexts: MultivariateStatistics`Private so the code will be transparent)

Really quick and not elegant fix for 2d case:

style[opts__, x_Ellipsoid] := Graphics[x] /. Line[y_] :> {opts, Polygon[y]} // First

ellips1 = Ellipsoid[{0.5`, 0.5`}, {10., 1.52}, {{0.4, 1.}, {-1.58, 1.}}];

          style[Red, ellips1],
          Rotate[style[Green, EdgeForm@Thick, Opacity@.5, ellips1]
                 , Pi/2]
         }, Frame -> True ]

You can use ?? like I said before to create more general solution, unfortunatelly I'm run out of time now :/. Good luck.

enter image description here

  • $\begingroup$ @AlejandroGuarnizo I'm glad you like it. It is good habit to hold on with an accept a little bit. It can discourage otheres. Here for example might be some easy fix I don't know because I'm not familiar with this package :) $\endgroup$
    – Kuba
    Sep 20 '13 at 14:00
  • $\begingroup$ Thanks @Kuba for your answer, it works. But now I have other one. What if instead one ellipse, I have two. It seems there is no way to show somehow one behind the other? $\endgroup$ Sep 20 '13 at 14:06
  • $\begingroup$ @AlejandroGuarnizo The overlap problem is much harder and has been discussed a number of time in this site. A quick search shows this mathematica.stackexchange.com/questions/28997/…. Id suggest if you cant find a satisfactory existing answer you should post that as a new question. $\endgroup$
    – george2079
    Sep 20 '13 at 14:27
  • $\begingroup$ another link: mathematica.stackexchange.com/questions/11146/… $\endgroup$
    – george2079
    Sep 20 '13 at 14:32
  • $\begingroup$ @AlejandroGuarnizo Take a look at my edit, does it work for you? $\endgroup$
    – Kuba
    Sep 20 '13 at 19:33

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.