Hello, I’m using the Plotly library in Python, specifically the figure_factory
module and the create_ternary_contour
function, to create a ternary contour diagram. I’d like to customize the color scale of the diagram, but so far, I’ve only been able to use the default color scales provided by the function.
When I try to change the colors in the ternary diagram, I’ve found that create_ternary_contour
seems limited to using only default color scales. My question is whether anyone knows a way to define a custom color scale for this function or if there’s an alternative method to modify it.
Environment:
Python 3.9
Plotly 5.15.0 (please replace if you’re using a different version)
Operating System: Windows 10
import plotly.figure_factory as ff
import numpy as np
# Sample data setu
A = [0.1, 0.2, 0.7]
B = [0.6, 0.2, 0.1]
C = [0.3, 0.6, 0.2]
Value = np.array([1, 2, 3])
fig = ff.create_ternary_contour(np.array([A, B, C]), Value,
colorscale='YlGnBu',
)
fig.update_layout(
title="Ternary Diagram with Custom Colors"
)
fig.show()
What I’ve Tried:
- I searched the documentation and forums but couldn’t find a solution to define a custom color scale.
- I attempted using methods like
update_traces
andcolorscale
, but they don’t seem to affect this type of plot.
Additional Question:
Along with the color issue, does anyone know how to modify the interactive tooltip that appears when hovering over points in the ternary diagram? I would like to customize the content or format of this tooltip.
Thanks in advance for any help or suggestions!