简体   繁体   中英

How to make a clear date display on the axis (Altair)?

My code

total_cases_graph = alt.Chart(subset_data).transform_filter(
    alt.datum.confirmed > 0
).mark_line().encode(
    x=alt.X('date:T', type='nominal', title='Date'),
    y=alt.Y('sum(confirmed):Q',  title='Confirmed cases'),
    color='region_name',
    tooltip='sum(confirmed)',
).properties(
    width=1000,
    height=500
).configure_axis(
    labelFontSize=17,
    titleFontSize=20
)

Now it is displayed like this

在此处输入图像描述

I would like the dates to be less frequent, ie some dates were displayed at intervals

Work

    total_cases_graph = alt.Chart(subset_data).transform_filter(
        size
    ).mark_line().encode(
        x=alt.X('date:T', type='temporal', title='Date'),
        y=alt.Y('sum(' + type + '):Q',  title=type_title),
        color='region_name',
        tooltip='sum(' + type + ')',
    ).properties(
        width=1000,
        height=500
    ).configure_axis(
        labelFontSize=17,
        titleFontSize=20
    )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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