0
$\begingroup$

I am noticing that regions are not correctly displayed and often have incorrect corners.

Example 1

Clear[ternary, reg, sol, tern];
ternary[{p1_, p2_, p3_}] = {p1 + 1/2 p2, Sqrt[3]/2 p2};
reg[a_] := ImplicitRegion[{x/z >= 1 - 2*a, {x, y, z, a} >= 0, x + y + z == 1}, {x, y, z}];
sol[a_] := {x, y, z} /. FindInstance[{x, y, z} \[Element] reg[a], {x, y, z}, 1];
tern[a_] := TernaryListPlot[sol[a], Prolog -> {LightBlue, DiscretizeRegion[TransformedRegion[reg[a], ternary]]}, PlotStyle -> Transparent]
tern[0.1]
tern[0.2]
tern[0.3]

Only the second output is correct - the other top corners are incorrect.

enter image description here

Example 2

    Clear[ternary, sol, reg, tern];
ternary[{p1_, p2_, p3_}] = {p1 + 1/2 p2, Sqrt[3]/2 p2};
reg := ImplicitRegion[{y >= 0.5, {x, y, z} >= 0, x + y + z == 1}, {x, y, z}];
sol := {x, y, z} /. FindInstance[{x, y, z} \[Element] reg, {x, y, z}, 1];
tern = TernaryListPlot[sol, Prolog -> {LightBlue, DiscretizeRegion[TransformedRegion[reg, ternary]]}, PlotStyle -> Transparent]

enter image description here

$\endgroup$
2
  • 6
    $\begingroup$ This is not a problem of TernaryListPlot but of ploting (discretizing) the region. You can make a finer discretization with DiscretizeRegion[..., MaxCellMeasure -> 1/1000]. $\endgroup$
    – Domen
    Sep 21, 2022 at 19:06
  • $\begingroup$ Great, it worked - thank you! $\endgroup$
    – Tom
    Sep 21, 2022 at 19:12

1 Answer 1

4
$\begingroup$
  • Since the region is the part of simplex (flat plane),we can try to use MaxCellMeasure -> ∞ in some cases.

  • I final found out that we need not define ternary[{p1_, p2_, p3_}] = {p1 + 1/2 p2, Sqrt[3]/2 p2}; as in my previous answer since TernaryListPlot directly support ternary elments. Here we disretize the 3D reg and extract its 2-dimensinal embeded 3D polygons by polygons=MeshPrimitives[dreg, 2].

  • Use Simplex and HalfSpace can improve the result.

Clear[reg, sol, dreg,polygons];
reg = ImplicitRegion[{y >= 0.5, {x, y, z} >= 0, x + y + z == 1}, {x, 
    y, z}];
sol = {x, y, z} /. 
   FindInstance[{x, y, z} ∈ reg, {x, y, z}, 10];
dreg = DiscretizeRegion[reg, {{0, 1}, {0, 1}, {0, 1}}, 
   MaxCellMeasure -> .001];
polygons = MeshPrimitives[dreg, 2];
TernaryListPlot[sol, Prolog -> {LightBlue, polygons}, 
  PlotStyle -> Red]

enter image description here

Clear[reg, sol, dreg, polygons];
a = .3;
reg = RegionIntersection[Simplex[IdentityMatrix[3]], 
   HalfSpace[-{1, 0, -(1 - 2*a)}, 0]];
dreg = DiscretizeRegion[reg, MaxCellMeasure -> ∞];
polygons = MeshPrimitives[dreg, 2];
sol = {x, y, z} /. 
   FindInstance[{x, y, z} ∈ reg, {x, y, z}, 10];
polygons = MeshPrimitives[dreg, 2];
TernaryListPlot[sol, Prolog -> {LightBlue, polygons}, 
 PlotStyle -> Red]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.