Skip to content

Allow to set set axis scaleanchor and scaleratio in template #3499

Closed
@messismore

Description

@messismore

It is currently not possible to set an axis' scaleanchor and scaleratio in a template:

import plotly.io as pio
import plotly.graph_objects as go

 pio.templates["constrained_axes"] = pio.templates["plotly_white"]
 pio.templates["constrained_axes"].update( go.layout.Template(
    layout_title="constrained_axes",
    layout_xaxis=dict(
        visible = False,
    ),
    layout_yaxis=dict(
        visible = False,
        scaleanchor = 'x',  #
        scaleratio = 1      #  these are currently ignored
    )
))

Using the template in a figure will render axes with different scales:

fig = px.line(df, 
        x="x", 
        y="y", 
        color="color", 
        template="constrained_axes")
fig.show()

It should render like this:

fig.update_yaxes(scaleanchor = "x", scaleratio = 1)
fig.show()

I'm plotting online.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions