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.

Axis year strings being reformatted as numbers and interpolated

See original GitHub issue

Maybe I’m just nuts, but I can’t figure this out. When I pass an array of stringified years as data to Plotly, it interpolates the strings as numbers:

Note that it shows my years as “2013”, but then interpolates them as “2,013.5”. Ugh.

It seems likely that tickformat could help me here, but I’ve looked at and and none of those options seem to help. They change the value, but nothing fixes it for real.

IF I have multiple years ['2014', '2015'], then setting tickformat: 'd' “works”. That feels like a violation of the spirit of what I want, though: a year is not a decimal number, it’s a string. And I’m passing it in as a string, not a decimal number.

And perhaps a related bug: with only one year tickformat: 'd' doesn’t work either. It hides the label entirely:

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

etpinardcommented, Dec 21, 2015

@tlrdstd plotly.js considers all numeric strings as numbers (i.e. floating points numbers) throughout the code. The main reason for this is to have a seamless API for folks feeding plotly.js with numeric strings coming from DOM nodes.

In your case, you can tell plotly.js that your data represent strings (or categories in plotly.js lingo) by adding type: 'category' in the axis attributes. See

Note that there is currently no way to customize the order of the categories, plotly.js plots them in the order of the input data. We hope to add an ordering axis attribute soon.

etpinardcommented, Jun 8, 2018

@ronyarmon please ask questions of the likes on

Read more comments on GitHub >

github_iconTop Results From Across the Web

python plotly date axis as string not dates - Stack Overflow
To do this, I suggest you do pd.date_range() so that you're getting a list of dates with plotly date format, then, manually set...
Read more >
Plotting time-series data — Climate Data Store Toolbox 1.1.5 ...
This guide shows you how to plot time-series data using Python's Plotly library. Graphs are referred to as “charts” in Python terminology, and...
Read more >
Dygraphs — options reference
num_or_millis: The value to be formatted. This is always a number. For date axes, it's millis since epoch. You can call new Date(millis)...
Read more >
plotly.graph_objects.Figure — 5.11.0 documentation
If the axis type is “date”, it should be date strings, like date data, ... of the year as a decimal number as...
Read more >
the C3 reference - C3.js | D3-based reusable chart library
Format string is also available for timeseries data. ... We can change the number of ticks to be shown by axis.x.tick.culling.max.
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 Post

No results found

github_iconTop Related Hashnode Post

No results found