You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: offset dash linestyle has no effect in patch objects #22977
the patch edge lines overlap, not adhering to the offset.
Expected outcome
Haven't been able to get any patch objects to have a proper offset on the edge line style but the expected outcome is shown here with Line2D objects
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
ax_g = plt.gca()
x = np.linspace(0, np.pi*4, 100)
y = np.sin(x+np.pi/2)
z = np.sin(x+np.pi/4)
w = np.sin(x)
plt.plot(x, y, ls=(0, (10, 10)), color='b')
plt.plot(x, y, ls=(10, (10, 10)), color='r')
plt.show()
Additional information
I have tried the Ellipse patch object as well and found the same issue. I also reproduced in Ubuntu 18.04 VM running matplotlib 3.5.0 with agg backend.
On one hand, we will sort out how to manage changing behavior when we need to, but on the other hand we need to have a very good reason to change long-standing behavior!
I'd like to use edge colors (red/blue) to denote a binary property of an entity represented by a rectangular patch that may overlap exactly with another entity with the opposite property value. When they overlap I'd like to easily see the two colors -- which isn't possible by just using low alphas.
Admittedly this is both a niche use case and can be worked around by hacking the onoffseq as so
I couldn't find a reason why we should ignore dash offset here. If this was intended, we should issue a warning if the user sets a non-zero value. However I rather think this was an oversight and even though noticed, nobody bothered to take action.
This is a niche feature that almost nobody will use. But AFAICS, there's little harm in supporting offests here. The only user code we could break with that is if users would explicitly have set an offset but rely on it not being applied. That's not something we'd have to guard against. To me this is simply a bug (affecting very little users), and we could fix it right away.
Marking this as good first issue as there is a minor modification required. Most work will be related to tests, probably an equality test with the workaround and the fixed code, and writing a sensible user release note clarifying that this has been fixed.
Activity
oliverpriebe commentedon May 4, 2022
Upon digging deeper into this issue it appears that this actually the intended behavior:
matplotlib/lib/matplotlib/patches.py
Line 588 in f8cd2c9
So it might be prudent to just update the docstring to reflect this fact.
I'm curious why this was made the default behavior though
oliverpriebe commentedon May 5, 2022
replacing the 0 here with the passed offset works completely fine on my OSX and Ubuntu setups.
matplotlib/lib/matplotlib/patches.py
Line 590 in f8cd2c9
tacaswell commentedon May 5, 2022
@oliverpriebe Why do you want to do this?
On one hand, we will sort out how to manage changing behavior when we need to, but on the other hand we need to have a very good reason to change long-standing behavior!
oliverpriebe commentedon May 5, 2022
I'd like to use edge colors (red/blue) to denote a binary property of an entity represented by a rectangular patch that may overlap exactly with another entity with the opposite property value. When they overlap I'd like to easily see the two colors -- which isn't possible by just using low alphas.
Admittedly this is both a niche use case and can be worked around by hacking the onoffseq as so
oliverpriebe commentedon May 5, 2022
but it might save the next poor soul some time if the docstring was updated
timhoffm commentedon May 5, 2022
I couldn't find a reason why we should ignore dash offset here. If this was intended, we should issue a warning if the user sets a non-zero value. However I rather think this was an oversight and even though noticed, nobody bothered to take action.
matplotlib/lib/matplotlib/patches.py
Line 588 in d1f6b76
This is a niche feature that almost nobody will use. But AFAICS, there's little harm in supporting offests here. The only user code we could break with that is if users would explicitly have set an offset but rely on it not being applied. That's not something we'd have to guard against. To me this is simply a bug (affecting very little users), and we could fix it right away.
oscargus commentedon Jun 4, 2022
Marking this as good first issue as there is a minor modification required. Most work will be related to tests, probably an equality test with the workaround and the fixed code, and writing a sensible user release note clarifying that this has been fixed.