question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Extending domain of time-based x-axis

See original GitHub issue

Sorry 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:

vega 9

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:closed
  • Created 6 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
afonitcommented, Mar 9, 2018

@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

1reaction
eitanleescommented, Mar 7, 2018

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))

Read more comments on GitHub >

github_iconTop Results From Across the Web

D3.js: calculate x-axis time scale for bar graph? - Stack Overflow
Expand your domain to be +1 and -1 month from the actual extent of your data. That will pad the graph with the...
Read more >
Mixed Domain Instrument Technology
By domain, we mean a parameter of a signal other than amplitude, that is generally displayed on the X axis. A traditional oscilloscope ......
Read more >
Configure Time Scope Block - MATLAB & Simulink - MathWorks
Position (%) — Specify the position of the time pointer along the y-axis. ... Run your model and open the Time Scope block...
Read more >
A Kinetic Molecular Model of the Reversible Unfolding and ...
We simulated the effect of AFM tip extension on a hypothetical titin molecule ... 1995) and develop a domain concentration-dependent, discrete time-based ......
Read more >
Tutorial: Time Series Analysis with Pandas - Dataquest
Time-based indexing; Visualizing time series data; Seasonality; Frequencies; Resampling; Rolling windows; Trends. We'll be using Python 3.6, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found