Different results with plotly ternary vs python-ternary
See original GitHub issueHello, Thank you so much for making this package! I’d like to overlay heatmap + scatter as mentioned in this issue: https://github.com/marcharper/python-ternary/issues/129 and addressed in https://github.com/marcharper/python-ternary/issues/121. However, I’m having trouble using the library.
I’m plotting median values of gene expression of a cell type across three species. When I use plotly, the result makes sense to me, where there are many dots in the middle, indicating many shared genes:
However, when I use that same data for python-ternary
, the result didn’t make any sense to me. There’s a bunch of points outside of the plot, and it’s not clear what’s happening to the rest. The code is in “Details” below.
Here is the code:
import ternary
def threewayplot(data, title=None):
fig, tax = ternary.figure()
tax.scatter(data.values.tolist())
tax.set_title(title)
tax.boundary(linewidth=1.0)
corner_offset = 0.005
tax.right_corner_label(data.columns[0], offset=corner_offset)
tax.top_corner_label(data.columns[1], offset=0.12)
tax.left_corner_label(data.columns[2], offset=corner_offset)
tax.gridlines(color="blue", multiple=5)
tax.ticks()
tax.get_axes().axis('off')
tax.clear_matplotlib_ticks()
fig.tight_layout()
threewayplot(df_nonzero_for_ternary)
I thought this was a simple rescaling issue and divided each column by the maximum so there were no values greater than 0, but this didn’t replicate the results I saw in Plotly, and don’t make sense to me as there are still dots outside of the plot, and the pattern doesn’t match what I see in plotly:
threewayplot(df_nonzero_for_ternary/df_nonzero_for_ternary.max())
Do you know what may be happening?
Here is the data for reference: medians.csv.txt
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
It could be useful to check that the sum isn’t equal to
scale
(and maybe that the values are all positive) warning the user if not. If you’d like to try to add it, feel free to open a PR! Maybeproject_point
is a good place to add the check, or a function inTernaryAxesSubplot
that the other plotting functions can call when they receive data.@marcharper
Indeed, there are so many ways to normalize data sets and it is up to users to decide what is the best way. However, I do think that it will be very helpful to let know new users of this nice package that the coordinates must sum to a constant (either 1 or 100, or even something else). Including the link to wikipedia will be an extra benefit!
And again, many thanks for such great package!