我有一个Scattergl图,我希望它旁边有两个或三个颜色条。每个颜色条具有与不同数据功能相关的不同色标。图中的点被着色为两种或三种色标颜色的组合。我已经有了颜色部分的组合,但是我不知道如何绘制颜色条...而且我不确定是否可以绘制多个颜色条。您对如何执行此操作有任何想法吗?
非常感谢您的帮助!提前致谢。亲切的问候。
很高兴看到更多使用sansanos的情况,为此,标记的颜色栏中有一个属性trace.marker.colorbar.x
,它需要一个介于-2到3之间的值,其中0是图的左极限,而1是图的左极限。限制,通常必须通过反复试验才能获得它。
请记住,提供示例代码总是很有用的,因此我们可以按照您正在研究的范式进行更正。这是一个例子
from plotly import graph_objects as go
data_x = [1, 2, 3, 4, 5, 6]
data_y = [1, 4, 9, 16, 25, 36]
figure = go.FigureWidget()
# First
first_scatter = go.Scattergl()
first_scatter.mode = 'markers'
first_scatter.x = data_x
first_scatter.y = data_y
first_scatter.marker.colorscale = 'Viridis'
first_scatter.marker.color = data_y
first_scatter.marker.size = 20
first_scatter.marker.showscale = True
first_scatter.showlegend = False
figure.add_trace(first_scatter)
# Second
second_scatter = go.Scattergl()
second_scatter.mode = 'markers'
second_scatter.x = data_x
second_scatter.y = data_y[::-1]
second_scatter.marker.colorscale = 'Electric'
second_scatter.marker.color = data_y
second_scatter.marker.size = 20
second_scatter.marker.showscale = True
second_scatter.marker.colorbar.x = 1.15 # Here
second_scatter.showlegend = False
figure.add_trace(second_scatter)