Skip to content

Temporary styling ignores color cycle #11376

Closed
@rjurga

Description

@rjurga

Bug report

Bug summary

With temporary styling, using colors with respect to the color cycle, like 'C0', is ignored if plt.show() is called outside of the with block. It only works properly if plt.show() is called inside the block.

Code for reproduction

This reproduces the bug:

import matplotlib.pyplot as plt

with plt.style.context('seaborn'):
    plt.axhline(0, color='C0')
    plt.axhline(1, color='C1')
    plt.axhline(2, color='C2')
plt.show()

This works fine and is the expected behavior:

import matplotlib.pyplot as plt

with plt.style.context('seaborn'):
    plt.axhline(0, color='C0')
    plt.axhline(1, color='C1')
    plt.axhline(2, color='C2')
    plt.show()

Actual outcome

does_not_work

Please note that other elements of the style are working fine, such as the grid.

Expected outcome

works

Matplotlib version

  • Operating system: Solus Linux
  • Matplotlib version: 2.2.2
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.6.5

Using matplotlib packaged by the linux distribution.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions