5

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

matrix1={{1,4},{6,8}}

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

Kuba
  • 136,707
  • 13
  • 279
  • 740

1 Answers1

8

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.}}];

Graphics[{
          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

Kuba
  • 136,707
  • 13
  • 279
  • 740
  • @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 :) – Kuba Sep 20 '13 at 14:00
  • 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? – Alejandro Guarnizo Sep 20 '13 at 14:06
  • @AlejandroGuarnizo The overlap problem is much harder and has been discussed a number of time in this site. A quick search shows this http://mathematica.stackexchange.com/questions/28997/opacity-and-overlapping-multiple-polygons. Id suggest if you cant find a satisfactory existing answer you should post that as a new question. – george2079 Sep 20 '13 at 14:27
  • another link: http://mathematica.stackexchange.com/questions/11146/how-to-quickly-calculate-intersections-of-filled-curves – george2079 Sep 20 '13 at 14:32
  • @AlejandroGuarnizo Take a look at my edit, does it work for you? – Kuba Sep 20 '13 at 19:33
  • @Kuba Yes...fantastic it works. I really appreciate your kind help!! :) – Alejandro Guarnizo Oct 14 '13 at 17:03