Skip to content

parcoords plots cannot handle date values #968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RZachLamberty opened this issue Mar 9, 2018 · 4 comments
Closed

parcoords plots cannot handle date values #968

RZachLamberty opened this issue Mar 9, 2018 · 4 comments

Comments

@RZachLamberty
Copy link

if you attempt to include a date dimension (standard datetime or numpy datetime64 objects) as one of the dimensions in the Parcoord graph object the resulting dimension is broken (no data points are included) and therefore so is the rest of the graph.

the following example will reproduce this behavior (plotly version 2.4.0, macos 10.13.3, conda distribution python 3.6.4):

import datetime
import numpy as np
import pandas as pd
import plotly.graph_objs as go
import plotly.offline

df = pd.DataFrame({
    'date': pd.date_range(start='2018-01-01', end='2018-12-31'),
    'value': np.random.random(365)
})
regular_dates = [
    datetime.datetime(2018, 1, 1) + datetime.timedelta(days=i)
    for i in range(365)
]

data1 = [
    go.Parcoords(
        dimensions=[
            {'values': df.date, 'label': 'date'},
            {'values': df.value, 'label': 'value'}
        ]
    )
]

# will fail to render correctly:
plotly.offline.plot(data1, filename='test1.html')

# just to be sure this isn't numpy date hell
data2 = [
    go.Parcoords(
        dimensions=[
            {'values': regular_dates, 'label': 'date'},
            {'values': df.value, 'label': 'value'}
        ]
    )
]

# also fails to render correctly:
plotly.offline.plot(data2, filename='test2.html')

both of these datasets (df.date and regular_dates) are perfectly acceptable inputs to other plotting types (e.g. go.Scatter).

@cldougl
Copy link
Member

cldougl commented Mar 9, 2018

Hi there,
The values attribute must be a list of finite numbers. We note this in the description here: https://plot.ly/python/reference/#parcoords-dimensions-values however on the reference page we are autogenerating the type and have incorrectly rendered that a list of strings or datetimes is acceptable (sorry for the confusion, I've opened an issue here to fix that doc error: plotly/documentation#891).

For your chart, you can use the ticktext and tickvals attributes to display the dates as done for dimension C in this example: https://plot.ly/python/parallel-coordinates-plot/#adding-dimensions , however your values will have to be a list of finite numbers.

@cldougl cldougl closed this as completed Mar 9, 2018
@harahu
Copy link

harahu commented Feb 17, 2023

Not sure I unserstand why this issue was closed. It makes perfect sense to want to display datetimes and timedeltas as continuous values in a parallel coordinates plot.

I suggest opening it again and treating it as a feature request.

@alexcjohnson
Copy link
Collaborator

@harahu looks like this was closed as “oops, our docs implied that you could do this already, but we’re fixing that to make clear you can’t.”

I agree this would be a reasonable thing to want to do. Also real category data or even log axes. This would need to happen in plotly.js, where there’s already this issue: plotly/plotly.js#2292 - doesn’t specifically mention dates but that would be a natural extension.

That said, both issues have been dormant for 5 years so absent a code or $ contribution it’s unlikely to be acted upon any time soon.

@harahu
Copy link

harahu commented Feb 17, 2023

Appreciate you pointing me in the right direction @alexcjohnson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants