Skip to content

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

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
edge-python opened this issue May 17, 2017 · 10 comments
Closed

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

edge-python opened this issue May 17, 2017 · 10 comments

Comments

@edge-python
Copy link

edge-python commented May 17, 2017

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
@WeatherGod
Copy link
Member

WeatherGod commented May 17, 2017 via email

@QuLogic
Copy link
Member

QuLogic commented May 17, 2017

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.

@QuLogic QuLogic closed this as completed May 17, 2017
@edge-python
Copy link
Author

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

@WeatherGod
Copy link
Member

WeatherGod commented May 18, 2017 via email

@edge-python
Copy link
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

@afvincent
Copy link
Contributor

afvincent commented May 18, 2017

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…

@edge-python
Copy link
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

@afvincent
Copy link
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.

@edge-python
Copy link
Author

edge-python commented May 18, 2017

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

@afvincent
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants