Latexify ternary Countour Plot Colobar

Hi @Sharma ,
Your ternary contour figure, with 25 contour lines, contains 28 traces, i.e. len(fig.data)=28.
fig.data[0] fills the entire triangle with the same color, figdata[-2] adds the pole names, and the last one, fig.data[-1],adds the colorbar. Hence each fig.data[k], for k=1, 2, …25, represents a contour plot. The trace name,
fig.data[k].name is a number that represents the contourline β€œheight”,
hence this one should be displayed.

To suggest how to add the contour line height at a few traces, just define a new figure and plot it,
to realize how difficult is to choose a particular position for that number.
Example, let us plot fig.data[15]:

Scatterternary({
    'a': array([0.67587022, 0.67653508, 0.67693866, ..., 0.67494656, 0.67497363,
                0.67587022]),
    'b': array([0.12722625, 0.13189232, 0.13668901, ..., 0.12268959, 0.12282173,
                0.12722625]),
    'c': array([0.19690353, 0.19157261, 0.18637232, ..., 0.20236385, 0.20220464,
                0.19690353]),
    'fill': 'toself',
    'fillcolor': 'rgb(206.923076923077, 255.0, 49.03846153846149)',
    'hoverinfo': 'skip',
    'line': {'color': 'rgb(150, 150, 150)', 'shape': 'spline', 'width': 1},
    'mode': 'lines',
    'name': '0.247',
    'showlegend': False
})

namely define a new figure, fig1, just to see the contour line shape and to decide where we can locate its height:

import plotly.graph_objects as go
k=15
tr= fig.data[15] #tr stands for trace
fig1=go.Figure(tr)
fig.update_traces(showlegend=False)
fig1.update_layout(width=400, height=400, font_family="Open Sherif")

contour-fig-data-15
Now let us update the initial figure, where are plotted all contour lines, the height of the above contour line:

m= len(tr.a)//4  #m is the point position where the text witll be displayed (i.e. the contour height)
text= tr.name
fig.add_scatterternary(a=[tr.a[m]], b=[tr.b[m]], c=[tr.c[m]],
                        mode="text", text=text, showlegend=False)

global-plot-with-contour-height
Notice that we cannot decide now which contour line has the height 0.247 :frowning:

If you intend to add a few heights on the plot, then you must repeat the experiment described above for some k in {1,2, …25}.
Pick up the position , m, of each point on a contour you selected for adding its height , and append each corresponding coordinate a, b, c, to a list of a-coords, b-coords, c-coords. Then the last line of code displayed above should be replaced by something like this:

fig.add_scatterternary(a=[fig.data[12].a[51], ... , fig.data[24],a[123]],  
                       b=[fig.data[12].b[51], ... , fig.data[24],b123]],
                       c=fig.data[12].c[51], ... , fig.data[24],c[123]], 
                       mode="text", text=[fig.data[12].name, ..., ,  fig.data[24].name], 
                      showlegend=False)

All strings in your initial code in ticktext = [r'$0.2$', r'$0.4$', r'$0.6$', r'$0.8$'] should be written simply, as 0.2, 0.4, etc,
and poles_labels as:

 pole_labels= ['AxesA', 'AxesB', 'AxesC']

Good luck!!! :slight_smile: