我有下面的 3 个图表,我想将第三个图表(“Autres”)的 X 轴标题与其他两个图表垂直对齐
我的代码如下
...
base = alt.Chart(data).properties(
width=250,
height=250
).add_selection(selector)
base2 = alt.Chart(data.loc[data.time.isin(l1)]).properties(
width=250,
height=250
).add_selection(selector)
base3 = alt.Chart(data.loc[data.time.isin(l2)]).properties(
width=250,
height=250
).add_selection(selector)
points = base.mark_point(filled=True, size=50,opacity=1).encode(
x=alt.X('trage',title="Tranche d'âge"),
y=alt.Y('mean(y)',title='NBV (%CA)',axis=alt.Axis(format='%')),
color=alt.condition(selector, 'Reseau_pat:O', alt.value('lightgray')),
#shape=alt.Shape('Segment:O', scale=alt.Scale(range=['circle', 'triangle'])),
tooltip = ['id','x','mean(y)']
)
timeseries = base2.mark_bar(opacity=1).encode(
x=alt.X('time', title='Structure de marge (%PM)'),
y=alt.Y('value',title='', scale=alt.Scale(domain=(-1, 1)),stack=None,axis=alt.Axis(format='.2f')),
#y2=alt.Y2('mean(duree)'),
color=alt.Color('Reseau_pat:O',
scale=alt.Scale(domain=domain, range=range_),
#legend=None
),
tooltip = ['value']
).transform_filter(
selector
)
test = base3.mark_bar(opacity=1,size=50).encode(
y=alt.Y('time', title='',axis=alt.Axis(orient='right')),
x=alt.X('value', title="Autres",scale=alt.Scale(domain=(0, 40)),stack=None),
color=alt.Color('Reseau_pat:O',
scale=alt.Scale(domain=domain, range=range_),
#legend=None
),
tooltip = ['value']
).transform_filter(
selector
)
points | timeseries | test
如果您有任何想法,将不胜感激