Remove border around vegaEmbed geoshape generated by altair?

允我心安 提交于 2019-12-24 03:59:31

问题


In the below image, observe the border around a map generated from Chart.save() to either HTML or JSON canvas (the border is inside the canvas, not CSS styled).

For any other type of mark, one would expect to be able to use Chart.configure_view() to set strokeWidth=0 to remove the border, but this does not appear to affect this geoshape chart.

The vegaEmbed embed options do not appear to document what creates this border.

Is it possible to style or remove the border?


回答1:


The way to remove the border is using configure_view(strokeWidth=0).

Here is an example, using the most recent version of Altair and the most recent version of 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
)

If you see different results, it might be that your frontend renderer is out of date, and you should make certain you're using the most recent version of Vega-Lite to render your chart.



来源:https://stackoverflow.com/questions/56638508/remove-border-around-vegaembed-geoshape-generated-by-altair

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!