Skip to content
Advertisement

Some Altair charts fade

Updated: Changing alt.X('yearmonthdate(TimeUTC):T' to alt.X('yearmonthdate(TimeUTC):O' made the problem go away. See bottom of post.

I have four years of data of the form:

TimeUTC FlightID DroneType
2018-08-22 19:35:23.024386+00:00 2018-08-22 19:35:23+00:00 663f-46fe-8887-d37895745506 MavicPro
2018-08-22 19:35:35.888933+00:00 2018-08-22 19:35:35+00:00 663f-46fe-8887-d37895745506 MavicPro
2018-08-22 20:05:06.239102+00:00 2018-08-22 20:05:06+00:00 a63a-4e01-b2d2-bdecc9027049 MavicPro

(There is, I think, a good reason for the microseconds in the index AND the TimeUTC column, but that is for another day.)

I plot this data by year. One set of graphs using mark_bar is produced as expected. Two of the four mark_area charts are very faded and a third is somewhat faded.

A "good" chart

A very faded chart

A somewhat faded chart

    chart = alt.Chart(chart_df).mark_area().encode(
        alt.X('month(TimeUTC):O', title='Month',axis=alt.AxisConfig(labelAngle=45)), 
        alt.Y('distinct(FlightID)', type='quantitative', title='Number of sUAS Operations'),
        alt.Color('DroneType', 
            type='nominal', 
            legend=alt.Legend(orient="bottom", columns=4), 
        scale=alt.Scale(domain=_domain, range=_range_))
    ).properties(
            title='Distribution of sUAS Flights by Model Over Time (Fig. 11)',
            width=400,
            height=200
        )

    chart.configure_title(
        fontSize=20,
        font='Courier',
        anchor='start',
        color='gray'
    )

All the charts use the same function and the data from the same data frame.

What might be causing this fade effect and how can I fix it?

Updated:

Original problem chart created with alt.X('yearmonthdate(TimeUTC):T':

Chart using :T

Chart using alt.X('yearmonthdate(TimeUTC):O':

Chart with :O

Advertisement

Answer

The fix, such as it is, required changing:

alt.X('yearmonthdate(TimeUTC):T

to

alt.X('yearmonthdate(TimeUTC):O

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement