Search code examples
pythonplotrotationplotlyternary

Ternary diagram rotation using plotly


Could someone, please, help with next question? How can I replace C by B, and B by C? Now I have ternary plot ACB (clockwise), but I want to get ABC (clockwise).

fig = px.scatter_ternary(df_small,a=df_small.Toluene, b =df_small.Benzene, c=df_small.Ethylbenzene,size_max = 10, opacity = [1,1],symbol_sequence = [1,0])
fig.update_layout({'ternary':  {'sum':1,
        'aaxis':{'title': ' A <br>','min': 0, 
                 'linewidth':2, 'ticks':'outside',
                 'tickmode':'array','tickvals':[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]},
        'baxis':{'title': '<br>B', 'min': 0, 
                 'linewidth':2, 'ticks':'outside',
                 'tickmode':'array','tickvals':[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]},
        'caxis':{'title': '<br>C', 'min': 0, 
                 'linewidth':2, 'ticks':'outside',
                 'tickmode':'array','tickvals':[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]}}})
fig.show()

enter image description here


Solution

  • I think you can switch the positions of B and C when you create the plotly.express figure. Then switch the titles as well.

    fig = px.scatter_ternary(df_small,a=df_small.Toluene, b=df_small.Ethylbenzene, c=df_small.Benzene,size_max = 10, opacity = [1,1],symbol_sequence = [1,0])
    fig.update_layout({'ternary':  {'sum':1,
            'aaxis':{'title': ' A <br>','min': 0, 
                     'linewidth':2, 'ticks':'outside',
                     'tickmode':'array','tickvals':[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]},
            'baxis':{'title': '<br>C', 'min': 0, 
                     'linewidth':2, 'ticks':'outside',
                     'tickmode':'array','tickvals':[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]},
            'caxis':{'title': '<br>B', 'min': 0, 
                     'linewidth':2, 'ticks':'outside',
                     'tickmode':'array','tickvals':[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9]}}})
    fig.show()