在 Altair 的分面图上设置字幕字体大小
Set subtitles font size on facet charts in Altair
如何编辑下面 example 中每个子图上方出现的年份的字体大小:
取自 altair 图库
import altair as alt
from vega_datasets import data
source = data.population.url
alt.Chart(source).mark_area().encode(
x='age:O',
y=alt.Y(
'sum(people):Q',
title='Population',
axis=alt.Axis(format='~s')
),
facet=alt.Facet('year:O', columns=5),
).properties(
title='US Age Distribution By Year',
width=90,
height=80
)
您可以在 facet
编码的 header
属性 中使用 labelFontSize
进行设置:
import altair as alt
from vega_datasets import data
source = data.population.url
alt.Chart(source).mark_area().encode(
x='age:O',
y=alt.Y(
'sum(people):Q',
title='Population',
axis=alt.Axis(format='~s')
),
facet=alt.Facet(
'year:O', columns=5,
header=alt.Header(labelFontSize=20)
),
).properties(
title='US Age Distribution By Year',
width=90,
height=80
)
有关可用 header 属性的完整列表和说明,请参阅 https://altair-viz.github.io/user_guide/generated/core/altair.Header.html
如何编辑下面 example 中每个子图上方出现的年份的字体大小: 取自 altair 图库
import altair as alt
from vega_datasets import data
source = data.population.url
alt.Chart(source).mark_area().encode(
x='age:O',
y=alt.Y(
'sum(people):Q',
title='Population',
axis=alt.Axis(format='~s')
),
facet=alt.Facet('year:O', columns=5),
).properties(
title='US Age Distribution By Year',
width=90,
height=80
)
您可以在 facet
编码的 header
属性 中使用 labelFontSize
进行设置:
import altair as alt
from vega_datasets import data
source = data.population.url
alt.Chart(source).mark_area().encode(
x='age:O',
y=alt.Y(
'sum(people):Q',
title='Population',
axis=alt.Axis(format='~s')
),
facet=alt.Facet(
'year:O', columns=5,
header=alt.Header(labelFontSize=20)
),
).properties(
title='US Age Distribution By Year',
width=90,
height=80
)
有关可用 header 属性的完整列表和说明,请参阅 https://altair-viz.github.io/user_guide/generated/core/altair.Header.html