使牛郎星散点图指定不同的颜色,而不是相同颜色的阴影

2024-04-25 23:10:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我想从altair复制这个图像,用示例中的代码生成:

alt.Chart(source).mark_circle(size=60).encode(
x='Vth',
y='mob',
color='Thickness',
tooltip=['Temperature', 'Thickness']
).interactive()e
source = Table_3

Altair example plot

然而,我对颜色的数据集选择是数字: Table_3.head()

这是我的代码:

source = Table_3

alt.Chart(source).mark_circle(size=60).encode(
    x='Vth',
    y='mob',
    color='Thickness',
    tooltip=['Temperature', 'Thickness']
).interactive()

这使牛郎星给我相同颜色的阴影。我希望它像例子中那样分开:

My plot


Tags: sourcesizecharttablealtinteractiveencodecolor
1条回答
网友
1楼 · 发布于 2024-04-25 23:10:47

通过在“厚度”字段中添加:N,可以告诉牛郎星这个数字实际上是名义上的,而不是定量的

alt.Chart(source).mark_circle(size=60).encode(
    x='Vth',
    y='mob',
    color='Thickness:N',
    tooltip=['Temperature', 'Thickness']
).interactive()

相关问题 更多 >