Skip to content

Multiple Y axes: only one scatterplot renders #1200

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
jason-curtis opened this issue Sep 25, 2018 · 3 comments
Closed

Multiple Y axes: only one scatterplot renders #1200

jason-curtis opened this issue Sep 25, 2018 · 3 comments
Labels
bug something broken

Comments

@jason-curtis
Copy link

This may be an issue in plotlyjs - if so, please point me to the right place.

When plotting data on multiple Y axes, particularly when nothing is plotted on the primary Y axis, sometimes plotly will only show one series.

Example code

# !pip install plotly
import datetime
from numpy import array

import plotly.graph_objs as go

import plotly
print(plotly.__version__) # 3.2.1

go.FigureWidget({
    'data': [{'marker': {'color': 'red', 'size': 5, 'symbol': 'circle-open'},
              'mode': 'markers',
              'name': 'r',
              'type': 'scatter',
              'uid': 'af705b50-c0ee-11e8-84dc-1208b1a853fd',
              'x': array([datetime.datetime(2015, 1, 1, 0, 0),
                          datetime.datetime(2015, 1, 2, 0, 0),
                          datetime.datetime(2015, 1, 3, 0, 0),], dtype=object),
              'y': [0.43369082538702236, 1.2898213293637133, 0.624430850249652,],
              'yaxis': 'y2'},
             {'marker': {'color': 'green', 'size': 5, 'symbol': 'circle-open'},
              'mode': 'markers',
              'name': 'g',
              'type': 'scatter',
              'uid': 'af705b51-c0ee-11e8-9e48-1208b1a853fd',
              'x': array([datetime.datetime(2015, 1, 1, 0, 0),
                          datetime.datetime(2015, 1, 2, 0, 0),
                          datetime.datetime(2015, 1, 3, 0, 0),], dtype=object),
              'y': [-0.30649578247834386, -1.0464786848889265, 1.911426735783162,],
              'yaxis': 'y3'},],
    'layout': {'xaxis': {'title': 'Time'},
               'yaxis': {'title': 'y axis number one',},
               'yaxis2': {'overlaying': 'y',
                          'title': 'y axis 2'},
               'yaxis3': {'overlaying': 'y',
                          'side': 'right',
                          'title': 'y axis 3'}}
})

Expected behavior

Two series are plotted

Actual behavior

Two series show up in the legend, but only one series is plotted:
image

Workaround

If you change 'y2' in the code above to 'y1', both series will show up. However, it's not always reasonable to assume there will be data on y1 - I am trying to write a purpose-specific API that uses plotly in such a way that I cannot guarantee there will be something on y1 without significant extra complexity.

@jason-curtis
Copy link
Author

I found another workaround - simply place a blank, invisible annotation on axis 1:

'layout': {
    ...
    'annotations': [{
        'yref': 'y',
        'xref': 'paper',
        'text': '',
        'showarrow': False,
        'visible': True,
    }],
    ....
}

This also causes both scatterplots to display correctly.

@jonmmease
Copy link
Contributor

Hi @thatneat ,

Thanks for the report, I see what you mean. Yes, I think this is something we should move to the plotly.js repo at https://github.com/plotly/plotly.js/issues. You can mention me in that plotly.js issue as well in case they have any questions on the Python side. Thanks!

@jason-curtis
Copy link
Author

Thanks @jonmmease , I'll close this since it clearly occurs without plotly.py . As you can see above I filed plotly/plotly.js#3074

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

No branches or pull requests

2 participants