Skip to content

Temporary styling ignores color cycle #11376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rjurga opened this issue Jun 5, 2018 · 7 comments
Closed

Temporary styling ignores color cycle #11376

rjurga opened this issue Jun 5, 2018 · 7 comments

Comments

@rjurga
Copy link

rjurga commented Jun 5, 2018

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.

@afvincent
Copy link
Contributor

@rjurga Thank you for the report :)!

I can reproduce this on master (with Fedora 28 and Python 3.6 from conda).

@afvincent afvincent added this to the v3.0 milestone Jun 5, 2018
@WeatherGod
Copy link
Member

WeatherGod commented Jun 6, 2018 via email

@tacaswell
Copy link
Member

It does look like the color is resloved at draw time, however for other things that hit the rcparams we resolve them at call time to exactly avoid issues like this.

We should probably move the resolution of the 'C#' values up sooner (have it be done in Line2D.set_color) and document the API change unless we can dig up documentation of why we did it this way.

@WeatherGod
Copy link
Member

WeatherGod commented Jun 6, 2018 via email

@jklymak
Copy link
Member

jklymak commented Jun 21, 2018

I dunno - I think if you drop out of context, you can/should expect strange things to do with the context to happen. i.e. in the code above, I'd plt.show or fig.savefig inside the context. Is this really a bug?

@WeatherGod
Copy link
Member

WeatherGod commented Jun 21, 2018 via email

@jklymak
Copy link
Member

jklymak commented Feb 9, 2019

I'm closing this as won't fix....

@jklymak jklymak closed this as completed Feb 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants