Extending domain of time-based x-axis
See original GitHub issueSorry for keep asking questions, but…
I have still been playing around with the stripplot and I am running this code currently:
alt.Chart(stripplot,
width=200,height=300,
description='Shows the frequency of terror attacks between two countries.',
config=alt.Config(
legend=alt.LegendConfig(orient="bottom-left")
)
).mark_tick(tickThickness=1.5, font="arial").encode(
x=alt.X('Qdate:T',axis=alt.Axis(format='%m/%Y',title='', labelAngle=0, axisWidth=0,ticks=4, orient="top",
)),
color=alt.Color('mostrecent:N',
legend=alt.Legend(
title='Tote',
),
scale=alt.Scale(
domain=['Aktuelle Attacke', 'Vorherige Attacken'],
range=['black', '#e23b3c'],
),
),).configure_scale(bandSize=100)
Which produces this output:
The reason for putting the legend down there is that I want to be able to also display the graphic on mobile. Now, I was wondering how to… -shorten the grey lines for the ticks -AND, more importantly: how to set a domain for datetime-values. I would like the whole x-axis start a bit before the first object and end a bit after the last object that is parsed in. However, even just reading in the first and the last element from a pandas dataframe that is sorted by date with something like:
paddedlate=(stripplot[“date”].iloc[0]) paddedearly=(stripplot[“date”].iloc[-1])
and passing these two dates into altair’s domain params results in a failure because the given values are timestamps. Hence, I was wondering, how to customize the x-axis in a way that is described here https://altair-viz.github.io/documentation/config.html#adjusting-axis-limits but just with a) a non-hardcoded way and b) a time-axis on x.
Again my sincere apologies for all these questions, but I am still relatively new to graphics viz.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (6 by maintainers)
Top GitHub Comments
@HalukaMB you need to use jupyter lab to view them. Here is a great write up Jake did to get people into a state where they can use it.: https://github.com/altair-viz/altair/wiki/Display-Troubleshooting
If all you want is padding you should be able to pass the
padding
keyword to x encoding scale.x=alt.X('Qdate:T', scale=alt.Scale(padding=20))