Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[MNT]: Unite property cycles for lines and patches #29468

Copy link
Copy link
Open
@timhoffm

Description

@timhoffm
Issue body actions

Summary

Loosely insprired by #19479.

We have separate property cycles for lines and patches. This is a source of confusion and IMHO doesn't give a benefit.

Proposed fix

Unite the property cycles so that an Axes has just one cycle to draw from, no matter what the Artist is.

  • Most simple plots use only either lines or patches. They wouldn't know the difference.
  • If plots have both lines and patches, e.g. one line, one bar plot, IMHO it's more clear to by default use different colors.
  • It's quite unlikely that people implicitly rely on synced colors to intentionally have parallelism between the lines and colors.

Migration:

  • Add/document a way to get the state of the next element in the cycle (as long as there are two, use the line cycle). This will enable explicit use of a cycle element for multiple artists like this:
    prop = ax.prop_cycle_next()
    ax.plot(..., color=prop['color'])
    ax.bar(... color=prop['color'])
    
  • Maybe consider ways to feed a cycle element back into a plotting function, either through an explicit kwarg ax.plot(..., prop=prop), or by ensuring that the cycle element can be dict-unpacked ax.plot(..., **prop).
  • Minimal announce this as upcoming change in the release notes. If people are relying on parallel cycles they should move to the above pattern.
  • We could also detect when both cyclers are used and issue a warning. The downside is that people will get a warning as soon as they use a mixture of lines and patches and they may be ok with the new behavior (it's unlikely they really intend to use the old behavior).

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.