Skip to content

Can't set numbered subplot axis using update in plotly.py 3.0.0 #1050

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
slishak opened this issue Jul 8, 2018 · 9 comments
Closed

Can't set numbered subplot axis using update in plotly.py 3.0.0 #1050

slishak opened this issue Jul 8, 2018 · 9 comments
Labels
bug something broken
Milestone

Comments

@slishak
Copy link

slishak commented Jul 8, 2018

I can create a Layout with a yaxis2 attribute using the following methods:

layout1 = go.Layout(yaxis2={'title': 'y2'})

layout2 = go.Layout()
layout2.yaxis2 = {'title': 'y2'}

layout3 = go.Layout()
layout3['yaxis2'] = {'title': 'y2'}

but not like this:

layout4 = go.Layout()
layout4.update(yaxis2={'title': 'y2'})

layout5 = go.Layout()
layout5.update({'yaxis2': {'title': 'y2'}})

because only xaxis and yaxis are valid properties for a Layout in the schema, so I get a ValueError.

@jonmmease
Copy link
Contributor

Thanks for the clear report @slishak. Yeah, looks like the special handling for numbered subplots is missing from the new version of update.

@jonmmease jonmmease added the bug something broken label Jul 9, 2018
@michaelbabyn
Copy link
Contributor

It looks like a similar thing happens when adding a Scatterpolar graph to a subplot with FigureWidget.
f.add_trace(go.Scatterpolar(r=[1,2,3,4,5],theta = [2,4,6,8,10]),row=2,col=1) will try to add {'xaxis':'x1', 'yaxis':'y2'} to the Scatterpolar object, but it fails to validate.

Is this the same problem?

@jonmmease
Copy link
Contributor

Note to self: Check if this is related to https://community.plot.ly/t/polar-subplots-in-plotly-py-3-0-0/11722

@jonmmease
Copy link
Contributor

@slishak and @michaelbabyn, see PR #1057 for progress. Thanks!

@jonmmease jonmmease modified the milestones: 1.7 Release, v3.0.1 Jul 17, 2018
jonmmease added a commit that referenced this issue Jul 17, 2018
* Fix for #1050. Can't create numbered subplots in update

* Added missing `mapbox` and `polar` subplot id support (See #1050)

* Handle .update on subplots with number 1 (e.g. xaxis1)

* Convert plotly objects to dicts before iterating over the in update.
This prevents unspecified values from being treated as None and overwriting everything
@jonmmease
Copy link
Contributor

jonmmease commented Jul 17, 2018

Fixed in 3.0.2

@jonmmease jonmmease modified the milestones: v3.0.1, v3.0.2 Jul 17, 2018
@slishak
Copy link
Author

slishak commented Jul 19, 2018

Thanks @jonmmease!

@slishak
Copy link
Author

slishak commented Jul 23, 2018

Looks like there's a little more to this one - I also can't use update for layout.shapes even with Plotly 3.1.0. The following code prints an empty tuple.

import plotly.graph_objs as go
layout = go.Layout()
shapes = [
    # Line Vertical
    {
        'type': 'line',
        'x0': 1,
        'y0': 0,
        'x1': 1,
        'y1': 2,
        'line': {
            'color': 'rgb(55, 128, 191)',
            'width': 3,
        },
    },
    # Line Horizontal
    {
        'type': 'line',
        'x0': 2,
        'y0': 2,
        'x1': 5,
        'y1': 2,
        'line': {
            'color': 'rgb(50, 171, 96)',
            'width': 4,
            'dash': 'dashdot',
        },
    },
    # Line Diagonal
    {
        'type': 'line',
        'x0': 4,
        'y0': 0,
        'x1': 6,
        'y1': 2,
        'line': {
            'color': 'rgb(128, 0, 128)',
            'width': 4,
            'dash': 'dot',
        },
    },
]
layout.update(shapes=shapes)
print(layout.shapes)

@jonmmease
Copy link
Contributor

Thanks @slishak , something different is going on here so I'm going to create a new issue

@jonmmease
Copy link
Contributor

Hi @slishak ,

I just pushed out release candidates for plotly.py 3.1.1 and plotlywidget 0.2.1. Installation instructions for the release candidates are at https://github.com/plotly/plotly.py/blob/bc1d4d188ab999cd9c21e3a7908729f156bc200f/README.md.

If you have a chance to confirm that this issue is resolved in the release candidate that would be awesome!

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

3 participants