Skip to content

Figure.update() misbehaviour in Python 2 #1462

Closed
@nicolaskruchten

Description

@nicolaskruchten

Consider the following code:

import plotly.graph_objs as go

def make_fig():
    return go.Figure(data=[
        go.Scatter(x=[1,2],y=[1,2], xaxis='x'), 
        go.Scatter(x=[2,3],y=[2,3], xaxis='x2')
    ])

fig = make_fig().update(layout= {
    'grid': {'xaxes': ['x', 'x2'], 'yaxes': ['y']}, 
    'xaxis': {'title': 'total_bill'}, 
    'xaxis2': {'matches': 'x', 'title': 'total_bill'}
})
print(fig.layout.xaxis2)

fig = make_fig().update(layout= {
    'grid': {'xaxes': ['x', 'x2'], 'yaxes': ['y'], 'yside': 'left', 'ygap': 0.1, 'xside': 'bottom'}, 
    'xaxis': {'title': 'total_bill'}, 
    'xaxis2': {'matches': 'x', 'title': 'total_bill'}
})
print(fig.layout.xaxis2)

In Python 3.6/plotly 3.7.0 it prints, as expected:

layout.XAxis({
    'matches': 'x', 'title': {'text': 'total_bill'}
})
layout.XAxis({
    'matches': 'x', 'title': {'text': 'total_bill'}
})

but in Python 2.7/plotly 3.7.0 it prints:

layout.XAxis({
    'matches': 'x'
})
layout.XAxis()

Note that the title didn't get set on the top one, and the matches didn't get set on the second one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions