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

Jos*_*ein 2 python vega vega-lite altair

在下图中,观察从Chart.save()HTML 或 JSON 画布生成的地图周围的边框(边框位于画布内部,而不是 CSS 样式)。

在此输入图像描述

对于任何其他类型的标记,人们希望能够使用Chart.configure_view()setstrokeWidth=0来删除边框,但这似乎不会影响此地理形状图表。

vegaEmbed嵌入选项似乎没有记录创建此边框的内容。

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

jak*_*vdp 6

去除边框的方法是使用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
)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

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