Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Axhline doesn’t cycle through colors #16714

Closed
@01baftb

Description

@01baftb

As requested by @story645, I am posting a possible bug I reported in the forum https://discourse.matplotlib.org/t/axhline-doesnt-cycle-through-colors/20938

When I plot horizontal lines using axhline, there resulting lines are all the same color. It doesn’t cycle automatically. Is this behavior expected? Do I need to manually setup the color cycling? If so how can I do this easily? Why does matplotlib not automatically cycle through the colors for axhline?

matplotlib v3.2.0

%matplotlib widget
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

count = 5

for n in range(count):
    ax.axhline(y=n**2, label=n) 
    
ax.legend()
plt.show()

image

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