Skip to content

cannot set default drawstyle (to 'steps-post') #12582

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
tsdlovell opened this issue Oct 21, 2018 · 8 comments
Closed

cannot set default drawstyle (to 'steps-post') #12582

tsdlovell opened this issue Oct 21, 2018 · 8 comments

Comments

@tsdlovell
Copy link

tsdlovell commented Oct 21, 2018

Bug report

Bug summary

Cannot set drawstyle default to 'steps-post' in 3.0.0

In 2.0.2 I could set the default drawstyle by settings rcParams['lines.linestyle']. In 3.0.0, it barfs.

Is there a different way to set this? I don't see any rcParams keys that reference drawstyle or look like they could be impacting drawstyle

Code for reproduction

Python 3.5.4 |Continuum Analytics, Inc.| (default, Aug 14 2017, 13:26:58)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import matplotlib

In [2]: matplotlib.__version__
Out[2]: '2.0.2'

In [3]: matplotlib.rcParams['lines.linestyle'] = 'steps-post'

In [4]: print(matplotlib.get_backend())
Qt5Agg

In 3.0.0, this happens

Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 17:14:51)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.0.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import matplotlib

In [2]: matplotlib.__version__
Out[2]: '3.0.0'

In [3]: matplotlib.rcParams['lines.linestyle'] = 'steps-post'
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~/.conda/envs/bamboo/lib/python3.6/site-packages/matplotlib/__init__.py in __setitem__(self, key, val)
    860             try:
--> 861                 cval = self.validate[key](val)
    862             except ValueError as ve:

~/.conda/envs/bamboo/lib/python3.6/site-packages/matplotlib/rcsetup.py in _validate_linestyle(ls)
    949     if isinstance(ls, (str, bytes, bytearray)):
--> 950         return _validate_named_linestyle(ls)
    951

~/.conda/envs/bamboo/lib/python3.6/site-packages/matplotlib/rcsetup.py in __call__(self, s)
     64         raise ValueError('Unrecognized %s string %r: valid strings are %s'
---> 65                          % (self.key, s, list(self.valid.values())))
     66

ValueError: Unrecognized linestyle string 'steps-post': valid strings are ['-', '--', '-.', ':', 'solid', 'dashed', 'dashdot', 'dotted', 'none', ' ', '']

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-3-7f838b7219da> in <module>
----> 1 matplotlib.rcParams['lines.linestyle'] = 'steps-post'

~/.conda/envs/bamboo/lib/python3.6/site-packages/matplotlib/__init__.py in __setitem__(self, key, val)
    861                 cval = self.validate[key](val)
    862             except ValueError as ve:
--> 863                 raise ValueError("Key %s: %s" % (key, str(ve)))
    864             dict.__setitem__(self, key, cval)
    865         except KeyError:

ValueError: Key lines.linestyle: Unrecognized linestyle string 'steps-post': valid strings are ['-', '--', '-.', ':', 'solid', 'dashed', 'dashdot', 'dotted', 'none', ' ', '']

In [4]: print(matplotlib.get_backend())
Qt5Agg
@tacaswell tacaswell added this to the v3.0.x milestone Oct 21, 2018
@tacaswell
Copy link
Member

attn @anntzer Did we change this intentionally?

@anntzer
Copy link
Contributor

anntzer commented Oct 21, 2018

That's been the case since #8040 (2.1.0) and I don't have anything to do with that :)
I do have #12442 to further separate drawstyles from linestyles (see also #11797 for the mess that linestyles currently are), but that's not even merged yet.
I think I remember @ImportanceOfBeingErnest suggesting somewhere to create a separate rcParam for drawstyle(?).

@tacaswell
Copy link
Member

Ah, I miss read the version @tsdlovell was starting with (sorry!)

I must have remembered seeing #12442 .

@tacaswell tacaswell modified the milestones: v3.0.x, v3.1 Oct 21, 2018
@ImportanceOfBeingErnest
Copy link
Member

#11797 concerns the linestyle. In addition I mentionned in #12493 about adding hist.histtype

plus 1 on adding the rcParameter. Equally, a lines.drawstyle rcParams would be useful.

I wasn't aware that step... could be used as lines.linestyle. This seems the wrong place for it and I strongly believe that step... should not be an allowed linestyle. Not sure what to do about this apparently being a regression though.

@tacaswell tacaswell modified the milestones: v3.1.0, v3.2.0 Mar 18, 2019
@timhoffm timhoffm modified the milestones: v3.2.0, v3.3.0 Aug 16, 2019
@torokati44
Copy link

Yes, we would also appreciate a lines.drawstyle key in rcParams.

@timhoffm
Copy link
Member

I'm not even sure, that should be a rc parameter. Steps is not a style but a fundamental change to the meaning of lines.

For your purposes, is it an option to use step() for plotting? That makes the intention more explicit.

@torokati44
Copy link

Yes, you do have a point, but it would be quite useful in practice.
In our use case, we're integrating Matplotlib into a simulator, for result analysis purposes.
The data series we'd like to plot can indeed have different properties, and therefore should be plotted differently. Being able to simply switch between "no lines", "linear interpolation" (what .plot() does), and the three steps- modes with a single variable, without having to add logic for switching between .plot() and .steps() would be nice.
Also, there might have been a good reason why lines.linestyle supported it, even if it wasn't the appropriate key for it.

@QuLogic QuLogic modified the milestones: v3.3.0, v3.4.0 May 7, 2020
@QuLogic QuLogic modified the milestones: v3.4.0, v3.5.0 Jan 27, 2021
@QuLogic QuLogic modified the milestones: v3.5.0, v3.6.0 Sep 25, 2021
@QuLogic QuLogic modified the milestones: v3.6.0, v3.7.0 Jul 8, 2022
@QuLogic QuLogic modified the milestones: v3.7.0, future releases Jan 26, 2023
@anntzer
Copy link
Contributor

anntzer commented Aug 20, 2024

Based on the discussion above and the lack of activity for years, I am going to claim that not supporting drawstyles in lines.linestyle is intentional (I still don't think it should be supported). If someone wants to put up a PR for adding lines.drawstyle this could be discussed with the PR.

@anntzer anntzer closed this as completed Aug 20, 2024
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

7 participants