Skip to content

Faulty shapes when axis type set to 'category' #759

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
ghost opened this issue May 23, 2017 · 2 comments
Closed

Faulty shapes when axis type set to 'category' #759

ghost opened this issue May 23, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented May 23, 2017

Shapes seem buggy when displayed on a time series plot with axis type set to 'category' while it is working as expected when set to 'auto' (date index).

If you zoom on the shape, you will clearly see that it is not what you intended to plot: it draws a rectangle instead of a vertical line in the case below. I have encountered that problem with different index format (datetime, integer, string) displayed as 'category'

import pandas as pd
import plotly.graph_objs as go
from plotly.offline import iplot, init_notebook_mode
from datetime import datetime

df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv")

data = [
    go.Scatter(
          x=df.Date,
          y=df['AAPL.Close']
    )
]

layout = go.Layout(
    xaxis=dict(
        type='category', # change this option to _auto_ for a correct shape
    ),
    shapes=[
        dict(
            x0=datetime(2015, 11, 5),
            y0=min(df['AAPL.Close']),
            x1=datetime(2015, 11, 5), # x1 = x0 for a vertical line
            y1=max(df['AAPL.Close'])
        )
    ]
)
fig = go.Figure(data=data, layout=layout)
iplot(fig)

Ouput:
screenshot from 2017-05-23 11-54-51

Zoom on the vertical line:
screenshot from 2017-05-23 11-51-03

@cldougl
Copy link
Member

cldougl commented May 24, 2017

Hi there,
Thanks for reporting this issue! It's actually in our underlying javascript library so I've opened an issue in that repo. I will close this issue in favour of: plotly/plotly.js#1720, once that's resolved, you will no longer see the problem with our python api.

@cldougl cldougl closed this as completed May 24, 2017
@sb0007
Copy link

sb0007 commented Sep 16, 2019

is this yet to be fixed?

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

2 participants