我是Altair的新手,我正在尝试使用对数刻度来制作颜色的热图,并且还选择非默认颜色方案(默认方案使用的程度很小,而且我也想要从浅到深的颜色).我发现我可以很容易地得到一个对数刻度type=log,但是一旦我这样做,scheme=那么该参数就会被忽略.如果我用手动设置高低颜色range=,那就可以了.
我进一步发现,如果我type=以任何方式明确设置type='linear',scheme=那么即使是显式设置(默认设置)也会被忽略.这是一个错误吗?如果没有,我怎样才能理解配色方案的使用方式?如果我不能直接使用方案,我如何检查方案并提取其颜色值以重复使用?
这里有些例子:
import numpy as np
import pandas as pd
import altair as alt
# This question is about Altair - plotnine is only here for the example data
from plotnine.data import diamonds
# This works, and gives me the greenblue color scheme:
alt.Chart(diamonds).mark_rect().encode(
x=alt.X('carat',bin=True),
y=alt.Y('price',bin=True),
color=alt.Color('count()',scale=alt.Scale(scheme='greenblue'))
)
# This gives me a log scale, but now the greenblue scheme is gone:
alt.Chart(diamonds).mark_rect().encode(
x=alt.X('carat',bin=True),
y=alt.Y('price',bin=True),
color=alt.Color('count()',scale=alt.Scale(type='log',scheme='greenblue'))
) …Run Code Online (Sandbox Code Playgroud)