Skip to content

update_*() batch methods #1484

Closed
Closed
@nicolaskruchten

Description

@nicolaskruchten

Given that px produces figures which often have non-trivial numbers of fairly 'regular' axes/annotations/traces, it would be very convenient to have something like Figure.update_traces( <patch>, <selector> )-type methods e.g.

px.scatter(..., marginal_y="violin").update_traces(
    patch=dict(marker_line_color="black"), 
    selector=dict(type="scatter")
)

In this example, px.scatter() generates some scatter traces but also some violin ones, so the patch will only apply to the scatter traces. Also note that this example uses some magic-underscores from #1481

This would also be very convenient for changing axis-level attributes in the case of a facetted px plot with many axes, ditto the annotation-based facet titles etc. In fact, I could see this being useful pretty much anywhere we have a collection of things either in a list (annotations, traces, shapes, etc) or with a number suffix (xaxis, yaxis, geo, scene, etc).

A more uniform API where all the method are called batch_update like Figure.data.batch_update() or Figure.layout.xaxis.batch_update() might work as well? The latter case maybe less nice, but there is no "collection" of x-axes on which to attach the method there :)

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