Skip to content

mpl 2.0.0 vs 2.0.1 line style with wx-backend #8637

Closed

Description

@edge-python

I have taken the base code from:

https://matplotlib.org/examples/user_interfaces/embedding_in_wx4.html
user_interfaces example code: embedding_in_wx4.py

I have added:

import matplotlib.widgets # .Cursor

and in class CanvasFrame:

    self.lineprops = dict(linewidth=0.5, linestyle='-.', color='#660099', alpha=1)
   
    self.line_cursor = matplotlib.widgets.Cursor(self.axes, **self.lineprops)

RESULT:
the line style in 2.0.1 (and 2.0.2) is very different to 2.0.0

I want the style of 2.0.0

What is the reason?

Thank you

2 0 0 vs 2 0 1

  • Operating System: Win 10 64bit
  • Matplotlib Version: 2.0.0 vs 2.0.1 (and 2.0.2)
  • Python Version: 3.6.1
  • Other Libraries: wx 4.0.0a1

Activity

  1. WeatherGod commented on May 17, 2017

    @WeatherGod
    Member
  2. QuLogic commented on May 17, 2017

    @QuLogic
    Member

    It's in API changes; this is not a bug, but a correction of less-desired behaviour. The line width is now actually consistent with the width you requested.

  3. edge-python commented on May 18, 2017

    @edge-python
    Author

    Thank you for your answer.
    but,
    these are not good news for me.

  4. WeatherGod commented on May 18, 2017

    @WeatherGod
    Member
  5. edge-python commented on May 18, 2017

    @edge-python
    Author

    oh, you are so fast
    I will try it

    Please allow me a statement:
    In mpl 2.0.0 very thin and sharp lines for the V and H lines are available for the cursor. But not so in mpl 2.0.1. This is a step back. I would appreciate it if the developers rethink that.
    Thank you

  6. afvincent commented on May 18, 2017

    @afvincent
    Contributor

    The API change is due to #8032 (the relevant commit is 276e1e9). Basically the former scaling scheme was dashes = unscaled_dashes * max(2, linewidth).

    In your case, what about something like

    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib.widgets import Cursor
    
    # Manually rescale the desired dash pattern
    # NB: plt.rcParams['lines.dashdot_pattern'] = [6.4, 1.6, 1.0, 1.6] but
    # one could simply define our own on-off ink sequence (in points)
    my_dashdot = [2.0*val for val in plt.rcParams['lines.dashdot_pattern']]
    cursor_props = dict(linewidth=0.5, dashes=my_dashdot, color='#660099')
    
    plt.close('all')
    fig, ax = plt.subplots()
    
    t = np.arange(0.0, 3.0, 0.01)
    s = np.sin(2*np.pi*t)
    ax.plot(t, s)
    
    line_cursor = Cursor(ax, **cursor_props)
    
    plt.show()

    capture d ecran de 2017-05-18 18-15-32

    Edit: English…

  7. edge-python commented on May 18, 2017

    @edge-python
    Author

    Thank you for the example.
    It looks better.
    I still need to figure out how to do it for matplotlib.figure
    ...
    I replaced plt.rcParams with matplotlib.rcParams and it seems to work.
    I hope I'm on the right track.

    many thanks for the support

  8. afvincent commented on May 18, 2017

    @afvincent
    Contributor

    I am pretty sure matplotlib.pyplot.rcParams is simply a convenient shortcut for matplotlib.rcParams.

    BTW, using the dash-dot pattern from rcParams was just a mean of showing that you could manually scale one of the default patterns. But you could also perfectly use your own dash sequence if you are not satisfied with it. See the Line2D docstring for a comprehensive description of the API, or simply this example to get a quick glance at the syntax. In a nutshell, a dash style is an even-length sequence of on/off ink (in points).

    PS: a similar way to customize the dashes may be to define a custom line style, which can be seen as a custom dash style prepended with an “offset” (usually set to zero...), following the pattern (offset, on-off-dash-seq). See for example here.

  9. edge-python commented on May 18, 2017

    @edge-python
    Author

    Thanks for your help, I'm not a professional developer even though I've created a complex Matplotlib application
    I'm glad to have the right cursor lines again

    anf-fit_plot
    ANT-fit plot

  10. afvincent commented on May 18, 2017

    @afvincent
    Contributor

    That's a nice looking application :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions