简体   繁体   English

Python 中的 Altair 图表:如何删除“HConcatChart”的复合图表边框

[英]Altair Chart in Python: how to remove the counpound chart border for the 'HConcatChart'

import altair as alt
from vega_datasets import data

iris = data.iris.url

chart1 = alt.Chart(iris).mark_point().encode(
    x='petalLength:Q',
    y='petalWidth:Q',
    color='species:N'
).properties(
    height=300,
    width=300
)

chart2 = alt.Chart(iris).mark_bar().encode(
    x='count()',
    y=alt.Y('petalWidth:Q', bin=alt.Bin(maxbins=30)),
    color='species:N'
).properties(
    height=300,
    width=100
)

alt.hconcat(chart1, chart2).ViewConfig(strokeWidth = 0)

Is there any way to make the border of these two horizontal charts disabled?有什么办法可以禁用这两个水平图表的边框? The.config_view is not available for compound charts. .config_view 不适用于复合图表。

Thanks.谢谢。

You can use the .configure_view() method on the concatenated chart to remove the view border in each subchart:您可以在连接图表上使用.configure_view()方法来删除每个子图表中的视图边框:


import altair as alt
from vega_datasets import data

iris = data.iris.url

chart1 = alt.Chart(iris).mark_point().encode(
    x='petalLength:Q',
    y='petalWidth:Q',
    color='species:N'
).properties(
    height=300,
    width=300
)

chart2 = alt.Chart(iris).mark_bar().encode(
    x='count()',
    y=alt.Y('petalWidth:Q', bin=alt.Bin(maxbins=30)),
    color='species:N'
).properties(
    height=300,
    width=100
)

alt.hconcat(chart1, chart2).configure_view(strokeWidth = 0)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM