I am trying to use different colours to plot components of a ContourPlot
in Mathematica. The contours are sufficiently complicated, such that I do not expect there to be a simple parametrisation. In my example
lim = 0.6; m = 1/6;
comp1 = -3 + 48 m^2 - 16 x - 128 m^2 x + 64 x^2 + 64 y^2;
comp2 = 81 m^2 - 1944 m^4 + 165888 m^8 - 27 x + 20736 m^4 x -
221184 m^6 x + 144 x^2 - 1728 m^2 x^2 + 27648 m^4 x^2 -
589824 m^6 x^2 - 576 x^3 - 36864 m^2 x^3 + 737280 m^4 x^3 +
6144 x^4 - 86016 m^2 x^4 + 688128 m^4 x^4 + 12288 x^5 -
786432 m^2 x^5 + 65536 x^6 - 262144 m^2 x^6 + 262144 x^7 -
2880 m^2 y^2 + 9216 m^4 y^2 + 589824 m^6 y^2 - 1344 x y^2 +
24576 m^2 x y^2 - 49152 m^4 x y^2 + 10240 x^2 y^2 -
303104 m^2 x^2 y^2 - 720896 m^4 x^2 y^2 + 40960 x^3 y^2 -
262144 m^2 x^3 y^2 + 131072 x^4 y^2 - 262144 m^2 x^4 y^2 +
786432 x^5 y^2 + 12288 m^2 y^4 + 688128 m^4 y^4 + 28672 x y^4 +
524288 m^2 x y^4 + 65536 x^2 y^4 + 262144 m^2 x^2 y^4 +
786432 x^3 y^4 + 262144 m^2 y^6 + 262144 x y^6;
c0 = ContourPlot[comp1 comp2 == 0, {x, -lim, lim}, {y, -lim, lim},
PlotPoints -> 200, ContourStyle -> Gray, ImageSize -> Small,
Axes -> True];
c1 = ContourPlot[comp1 == 0, {x, 0, lim}, {y, -lim, lim},
ContourStyle -> Blue];
c2 = ContourPlot[comp1 == 0, {x, -lim, 0}, {y, -lim, lim},
ContourStyle -> Red];
Show[c0, c1, c2]
I study the zero locus of a polynomial in $x$ and $y$, with $m>0$ as a parameter. The contour has various intersection points that partitions it into (here 7) components. I would like to plot each of these components in a different colour. Since the polynomial factorises into comp1
and comp2
, this can be done for one factor comp1
. In the picture, the blue and red components can be coloured by restricting the plotting domain. The other factor comp2
contains multiple components, but does not factor for generic $m>0$ (also not for the chosen $m=\frac16$). I was wondering whether there is a trick to give the remaining 5 components belonging to comp2
own colour. Many thanks for any suggestions!