删除由 altair 生成的 vegaEmbed geoshape 周围的边框?

Remove border around vegaEmbed geoshape generated by altair?

在下图中,观察从 Chart.save() 到 HTML 或 JSON canvas 生成的地图周围的边界(边界在 canvas,不是 CSS 样式)。

对于任何其他类型的标记,人们希望能够使用 Chart.configure_view() 设置 strokeWidth=0 以删除边框,但这似乎不会影响此 geoshape 图表。

vegaEmbed embed options 似乎没有记录创建此边框的原因。

是否可以设置样式或删除边框?

去除边框的方法是使用configure_view(strokeWidth=0)

这里是一个例子,使用最新版本的 Altair 和最新版本的 Vega-Lite:

import altair as alt
from vega_datasets import data

counties = alt.topo_feature(data.us_10m.url, 'counties')
source = data.unemployment.url

alt.Chart(counties).mark_geoshape().encode(
    color='rate:Q'
).transform_lookup(
    lookup='id',
    from_=alt.LookupData(source, 'id', ['rate'])
).project(
    type='albersUsa'
).configure_view(
    strokeWidth=0
)

如果您看到不同的结果,可能是您的前端渲染器已过时,您应该确保您使用的是最新版本的 Vega-Lite 来渲染您的图表。