Skip to content

[MNT]: Clarify the difference between Artist.set and Artist.update #30957

@timhoffm

Description

@timhoffm

Summary

Those functions are quite similar. In #30956, I tried to relate them via

a.update(props) is equivalent to a.set(**props)

And got the the question, why we have them both.

From a quick look at the code, it seems set is doing name normalization, so I wrote

        This is a slightly more efficient variant of `.Artist.set`. It's
        primarily intended to be used internally and by third party
        plotting libraries. End users are recommended to use the more
        readable and flexible `.Artist.set`.

        ``a.update(props)`` is equivalent to ``a.set(**props)``, but does
        not support aliases / shortcuts; e.g. you can do ``set(lw=1)`` as
        a shortcut for ``set_linewidth(1)``, but you cannot do
        ``update({"lw": 1})``.

But turns out that is not true either. While update does not normalize, it likely will just call set_lw().

This needs more investigation.

Proposed fix

Identify whether there are any behavior differences or whether it's just the API (props vs. **props).

This possibly involves digging into the history.

Document the findings and define the scope when/whether update should still be used.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions