# How can I plot this figure?

I have the formula, the renyi entropy $$\frac{1}{1-q}ln(\sum_{i=1}^Np_i^q)$$, and the figure I haven't seen before, is it the ContourPlot for N=3 (the condition is $$0\le p_1\le1,0\le p_2\le1,p_1+p_2+p_3=1$$)?

I only get this:

q = 2;
S1 = 1/(1 - q) Log[p1^q + p2^q + (1 - p2 - p1)^q];
ContourPlot[S1, {p1, 0, 1}, {p2, 0, 1}]


We need to use ternary coordinate,that is we need to mapping the set

{p1,p2,p3}, p1+p2+p3==1,p1>0,p2>0,p3>0


to {x,y} coordinate.

Clear[q, f, ternary, inverseternary, reg, inversereg];
q = 2;
f[{p1_, p2_, p3_}] = 1/(1 - q) Log[p1^q + p2^q + p3^q];
ternary[{p1_, p2_, p3_}] = {p1 + 1/2 p2, Sqrt[3]/2 p2};
inverseternary[{x_, y_}] = {p1, p2, p3} /.
Solve[{x == p2 + 1/2 p3, y == Sqrt[3]/2 p3,
p1 + p2 + p3 == 1}, {p1, p2, p3}][[1]];
reg = ImplicitRegion[{p1 > 0, p2 > 0, p3 > 0, p1 + p2 + p3 == 1}, {p1,
p2, p3}];
inversereg = TransformedRegion[reg, ternary];
ContourPlot[f[inverseternary[{x, y}]], {x, 0, 1}, {y, 0, 1},
RegionFunction -> Function[{x, y}, {x, y} ∈ inversereg],
Contours -> 20, PlotLegends -> Automatic]


• Amazing! You are so great! Aug 28, 2022 at 13:11
• What if I change the function with "-p1 Log[p1] - p2 Log[p2] - p3 Log[p3] + Log[p1^2 + p2^2 + p3^2]", should I change "p2 + 1/2 p3, Sqrt[3]/2 p3"? Aug 28, 2022 at 13:17
• @KarryMa For the coordinate transformation about ternary, we can read the document ref/TernaryListPlot or online reference.wolfram.com/language/ref/TernaryListPlot.html Aug 28, 2022 at 13:19
• So the picture I plot is in the rectangular coordinates and this is in barycentric coordinate system, right? Aug 28, 2022 at 13:24
• @KarryMa Yes,you are right. Aug 28, 2022 at 13:25