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
Linewidth(s) keywords not working with quiver #8630
This seems to be a regression in the behaviour of the quiver function
According to this SO post, quiver used to accept a linewidths array argument to set the arrow sizes; however, this is no longer true with 2.02 on Py2/3K.
The linewidth item pops 5 times in quiver.py though.
Code for reproduction
From the SO post, but the code (reported as working) does not work on my install.
importmatplotlib.pyplotaspltimportnumpyasnpsin=np.sincos=np.cos# http://stackoverflow.com/questions/6370742/#6372413xmax=4.0xmin=-xmaxD=20ymax=4.0ymin=-ymaxx=np.linspace(xmin, xmax, D)
y=np.linspace(ymin, ymax, D)
X, Y=np.meshgrid(x, y)
# plots the vector field for Y'=Y**3-3*Y-Xdeg=np.arctan(Y**3-3*Y-X)
widths=np.linspace(0, 2, X.size)
plt.quiver(X, Y, cos(deg), sin(deg), linewidths=widths)
plt.show()
Actual outcome
Output is the same as that of the initial SO post where the linewidths keyword is not set.
All of this seems to reflect a misunderstanding of what quiver does and how to control the arrow properties. Quiver uses a patch collection, so each arrow has a face and an outline. Turning on the outline makes sense only when one wants to have an outline of one color and a face of another color. Otherwise, just rely on the face. The basic arrow dimension kwargs include:
width : scalar, optional
Shaft width in arrow units; default depends on choice of units,
above, and number of vectors; a typical starting value is about
0.005 times the width of the plot.
headwidth : scalar, optional
Head width as multiple of shaft width, default is 3
headlength : scalar, optional
Head length as multiple of shaft width, default is 5
headaxislength : scalar, optional
Head length at shaft intersection, default is 4.5
minshaft : scalar, optional
Length below which arrow scales, in units of head length. Do not
set this to less than 1, or small arrows will look terrible!
Default is 1
minlength : scalar, optional
Minimum length as a multiple of shaft width; if an arrow length
is less than this, plot a dot (hexagon) of this diameter instead.
Default is 1.
So please use the width kwarg together with units; linewidths is only for controlling the outline thickness, when an outline of a different color is explicitly requested.
Reacted by Xuechen Li, Pranjal Rawat, Andrew Clark and Vidur
@dstansby this works great, thanks for the workaround! However, I still think this is a regression which should be fixed.
@efiring there is no misunderstanding : I (as well as the other people from the SO post) need a non scalar argument to set different widths for each arrow. Therefore, I work with the only non-scalar argument at my disposal, which is linewidths.
But if width can be modify to accept arrays, I totally agree that it would be better ;)
It is a feature, which, though you don't think it relevant, has been, and is still useful to users...
Couldn't this feature of an array widths/linewidths at least be put on the wishlist, then?
Activity
dstansby commentedon May 16, 2017
Can confirm this on master, the problem bisects to #6904
dstansby commentedon May 16, 2017
As a workaround, it looks like you have to explicitly set the
edgecolorskwarg to get what you want now, ie.:efiring commentedon May 16, 2017
All of this seems to reflect a misunderstanding of what quiver does and how to control the arrow properties. Quiver uses a patch collection, so each arrow has a face and an outline. Turning on the outline makes sense only when one wants to have an outline of one color and a face of another color. Otherwise, just rely on the face. The basic arrow dimension kwargs include:
So please use the
widthkwarg together withunits;linewidthsis only for controlling the outline thickness, when an outline of a different color is explicitly requested.Silmathoron commentedon May 16, 2017
@dstansby this works great, thanks for the workaround! However, I still think this is a regression which should be fixed.
@efiring there is no misunderstanding : I (as well as the other people from the SO post) need a non scalar argument to set different widths for each arrow. Therefore, I work with the only non-scalar argument at my disposal, which is
linewidths.But if
widthcan be modify to accept arrays, I totally agree that it would be better ;)efiring commentedon May 16, 2017
I really don't think this is a bug or regression, so I am closing it.
Silmathoron commentedon May 16, 2017
It is a feature, which, though you don't think it relevant, has been, and is still useful to users...
Couldn't this feature of an array widths/linewidths at least be put on the wishlist, then?