I am trying to plot a function defined on a simplex. Apparently, you can do it very nicely using the Matlab API.
But I cannot figure out how to do this using the Python API. The reference has a section named Ternary Contour Plots in Python but it does not plot a numeric function, but a function mapping the simplex to a given discrete set.
I tried to emulate the Matlab code:
import plotly as py
A = [0, .2, .2, .2, 0, .6, .75, .9, 0, 1, .8, .3]
B = [1, .2, .4, .1, 0, .4, .05, 0, .8, 0, .05, .3]
C = [0, .6, .4, .7, 1, 0, .2, .1, .2, 0, .15, .4]
Z = [.1, .5, .1, .2, 1, .8, .4, 0, .1, .6, 1, .7]
trace = {
"type": 'scatterternary',
"carpet": 'scattercontour',
"a": A,
"b": B,
"c": C,
"z": Z
}
layout = {
'title': 'Simple Ternary Contour Plot with Python'
}
figure = dict(data=[trace], layout=layout)
py.offline.plot(figure, validate=False)
But I get this plot instead:
If someone is still interested, here is a Jupyter Notebook to see how to generate a Plotly ternary contour plot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With