类似于seaborn在plotly中的色调功能? [英] similar to seaborn's hue function in plotly?

查看:58
本文介绍了类似于seaborn在plotly中的色调功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

geo1 = go.Scatter(
x=geo['Year'],
y=geo['Number'],
mode='lines',
marker=dict(color=geo['Geographical region'],size=4, showscale=False),
name='geo',
showlegend=True)


data = [geo1]

layout = dict(
title='Working VISA in UK by Regions',
xaxis=dict(title='Year'),
yaxis=dict(title='Number'), showlegend=True)
fig = dict(data=data, layout=layout)
iplot(fig)

结果显示:

我想要的是在seaborn中使用与'hue'类似的功能:

what I want is to use a similar function as 'hue' in seaborn:

如何对不同颜色的区域进行plotly编码?

how to do the plotly coding by regions in different colors?

推荐答案

问题解决:

traces=[]

for x, geo_region in geo.groupby('Geographical region'):

traces.append(go.Scatter(x=geo_region.Dates, y=geo_region.Number, name=x, mode='lines'))

fig = go.Figure(data=traces)
iplot(fig)

这篇关于类似于seaborn在plotly中的色调功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆