我的 Python Altair 图表中有更多颜色。更广泛的颜色范围

More colors in my Python Altair Chart. Wider spectrum of colors

早上好。我有以下图片:

对于以下代码:

data = pd.read_csv(os.path.join(path_to_folder,"file.csv"))

chart = alt.Chart(data.reset_index(),title="Visualisation").mark_point().encode(
    x ="x",
    y ="y",
    color = 'id_species'
).encode(tooltip=['x','y','id_species'])

chart.encoding.x.title = 'first parameter'
chart.encoding.y.title = 'second parameter'

chart.show()

如果我想让颜色从比方说紫色变为绿色,我该怎么做?如果我想要更广泛的颜色而不是蓝色阴影?*

(我用 matplotlib 做的,但我想用 Altair 做。)

This page from the altair documentation 介绍了如何更改配色方案。例如:

import altair as alt
from vega_datasets import data

iris = data.iris()

alt.Chart(iris).mark_point().encode(
    x='petalWidth',
    y='petalLength',
    color=alt.Color('species', scale=alt.Scale(scheme='dark2'))
)

你想要的配色方案在 altair 中被称为 'viridis',就像在 matplotlib 中一样。