将mark_geoshape旋转属性绑定到滑块选择



我正在尝试在Altair中重新创建类似于这个vega情节的东西。

我之前很幸运地构建了mark_geoshape映射,当绑定到类似color的东西时,它可以在encode函数中,但我一生都无法弄清楚如何将滑块绑定到图表的rotate属性,它存在于project

我以为我可以做这样的事情,但没有运气:

import altair as alt
from vega_datasets import data
# Data generators for the background
sphere = alt.sphere()
graticule = alt.graticule()
# Source of land data
source = alt.topo_feature(data.world_110m.url, 'countries')
slider = alt.binding_range(min=0, max=100, step=1, name='rotate:')
selector = alt.selection_single(name="SelectorName", fields=['rotate'],
bind=slider, init={'rotate': 180})
# Layering and configuring the components
alt.layer(
alt.Chart(sphere).mark_geoshape(),
alt.Chart(graticule).mark_geoshape(stroke='white', strokeWidth=0.5),
alt.Chart(source).mark_geoshape(fill='ForestGreen', stroke='black')
).project(
'orthographic',
).encode(
rotate=['rotate',180,180]
).properties(width=600, height=400, selection=selector).configure_view(stroke=None)

任何帮助将不胜感激。

谢谢 狮子座

目前在 Altair 中无法执行此操作:Vega-Lite 模式仅支持常量旋转值。如果您愿意,您可以在 Vega 中执行此操作;https://vega.github.io/vega/docs/projections/有一个例子。