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.

Set values for time axis

See original GitHub issue

I’m unclear as to how I might set the values for a time axis. I’m using Axis as follows…

Axis(title=my_title, values=my_values)

…and have tried setting my_values to a list of ISO formatted strings, datetime objects, datetime64 objects (np) and a DatetimeIndex object (pd). In each case, the stacktrace indicates that a float is required.

Thanks for any help in advance. I appreciate that this is less an issue and more a request for assistance, but there isn’t an Altair discussion forum.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kanitwcommented, Sep 1, 2016

This reminds me that we should support our DateTime Definition object (that we introduced for temporal filter) for axis/legend’s values as well (https://github.com/vega/vega-lite/issues/1516). So this will be reasonable to use when people use Vega-Lite from JSON.

That said, I think from Altair’s perspective, I think automatically date conversion to timestamp would be better. 😃

probably oweing to differing treatments of midnight between pandas and vega-lite.

Possibly because the timestamp is UTC but our label displays local time.
We’ll have to work on support for UTC (https://github.com/vega/vega-lite/issues/446).

cc: @domoritz

0reactions
iaindillinghamcommented, Sep 2, 2016

Hello everyone,

Thank you all for your time. It’s reassuring to find such a committed bunch of core developers!

I followed @jakevdp and passed timestamps to Axis. Rather than hard-coding dates, I used pd.date_range as follows:

date_min = '2016-01-01'
date_max = '2016-02-01'
my_values = list(pd.date_range(date_min, date_max, freq='W-MON').astype(int) / 10 ** 6)

The curious can find the associated notebook here. (It’s a quick exploration of bike usage in Bath, UK, which I prepared for an upcoming hack day.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

The time (vertical) axis is showing random seconds vs
Answer: · Click anywhere in the vertical axis to select it. Right-click and select Format Axis. · In the Axis Options: Minimum: Select...
Read more >
Setting Time Axis Values in Excel
For instance, I used 3 hours as the major division on the graph you are looking at and 1 hour for the minor...
Read more >
Time Axis - FusionCharts
Set the column name which you want to represent on the time axis as the value of the plot property. In this case,...
Read more >
Display or change dates on a category axis - Microsoft Support
In the chart, right-click the category axis, and then click Format Axis. · In the Format Axis pane, select the Axis Options tab....
Read more >
Display Data on a Time-Scale Axis - Windows Forms
To create a scatter chart with time values on the x-axis, use the Series collection with one or more NumericTimeSeries. The X-axis labels...
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