-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
FF ternary_contour - add cliponaxis #3960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
@alexcjohnson thanks for the suggestion, unfortunately this doesn't work (the code will run but the cliponaxis is not implemented). I believe this is to do with the fact the ternary_contour plot is part of the figure factory set and therefore might need to be implemented directly in the ff backend? |
Ah, I see - looks like whatever we did to create those contour lines includes lines around the border that don't really add any value... and to compensate we clip them and add border lines. If we undo that, you can see the unclipped markers. Here's one of the examples from https://plotly.com/python/ternary-contour/ but taking that out and adding import plotly.figure_factory as ff
import numpy as np
Al, Cu = np.mgrid[0:1:7j, 0:1:7j]
Al, Cu = Al.ravel(), Cu.ravel()
mask = Al + Cu <= 1
Al, Cu = Al[mask], Cu[mask]
Y = 1 - Al - Cu
enthalpy = (Al - 0.5) * (Cu - 0.5) * (Y - 1)**2
fig = ff.create_ternary_contour(np.array([Al, Y, Cu]), enthalpy,
pole_labels=['Al', 'Y', 'Cu'],
ncontours=20,
coloring='lines',
showmarkers=True)
fig.update_traces(cliponaxis=False)
ax_override = dict(min=0, linewidth=0) # the figure factory includes min=0.01, linewidth=2
fig.update_layout(ternary_aaxis=ax_override, ternary_baxis=ax_override, ternary_caxis=ax_override) I haven't looked into how hard it would be to remove those so this gives the exact behavior you want. |
Ah that's good to know. I was using the line mode to see the points more clearly, however, filling the contours makes the lines on the edge less noticeable. I have then added a scatter over the top using your solution: Here is the final output which looks great: I think this is a workable solution, so I'm happy to close this. Thanks for the help and quick responses @alexcjohnson |
Would it be possible to add the cliponaxis (as has been implemented for scatter ternary plots - see issue #1385 plotly/plotly.js#1385). This would allow the markers not to be cut off by the plot area when the showmarkers tag is set to true.
Currently I have a plot like so:
However, as he edge markers are cut off, it looks like I have less points. The plot below shows which points are plotted:
It would be really great to add this tag to the ff.ternary_contour plot, as it is so useful in the scatter ternary. If there is also a work around that I have missed, please let me know (I have had a go at this but can't find any way to get the markers not to be cut off).
Thanks
The text was updated successfully, but these errors were encountered: