From: Michael J G. <mic...@us...> - 2016-02-05 09:29:29
|
Currently, the length of the arrow as well as the size of the arrow head are scaled by the value of the "size" column, which can get out of hand quickly for vector field plots. Introduce an argument "arrowscale" (defaulting to 1) that makes the arrow head scale by a convex combination of "1" and the value of "size": 1 (default): scale by "size" as before 0: fixed size (as if the value of "size" were 1, just for the arrow head) Signed-off-by: Michael J Gruber <mic...@us...> --- I'll try and reply with two PNGs showing the output for arrowscale=0 (default) and arrowscale=1. Alternative to the RFC here, one could think about abstracting to graph.style.deco() with general decoargs and decokwargs arguments (defaulting to [arrowpos=0.5] and such). That would make it more complicated to specify a decorator which takes into account "size", though. pyx/graph/style.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyx/graph/style.py b/pyx/graph/style.py index 1d1e283..57cf2de 100644 --- a/pyx/graph/style.py +++ b/pyx/graph/style.py @@ -880,12 +880,13 @@ class arrow(_styleneedingpointpos): defaultlineattrs = [] defaultarrowattrs = [] - def __init__(self, linelength=0.25*unit.v_cm, arrowsize=0.15*unit.v_cm, lineattrs=[], arrowattrs=[], arrowpos=0.5, epsilon=1e-5, decorator=deco.earrow): + def __init__(self, linelength=0.25*unit.v_cm, arrowsize=0.15*unit.v_cm, lineattrs=[], arrowattrs=[], arrowpos=0.5, arrowscale=1, epsilon=1e-5, decorator=deco.earrow): self.linelength = linelength self.arrowsize = arrowsize self.lineattrs = lineattrs self.arrowattrs = arrowattrs self.arrowpos = arrowpos + self.arrowscale = arrowscale self.epsilon = epsilon self.decorator = decorator @@ -930,7 +931,7 @@ class arrow(_styleneedingpointpos): y2 = y_pt+(1-self.arrowpos)*dy*linelength_pt*size if self.decorator: privatedata.arrowcanvas.stroke(path.line_pt(x1, y1, x2, y2), - privatedata.lineattrs+[self.decorator(privatedata.arrowattrs, size=self.arrowsize*size)]) + privatedata.lineattrs+[self.decorator(privatedata.arrowattrs, size=self.arrowsize*((1-self.arrowscale) + self.arrowscale*size))]) else: privatedata.arrowcanvas.stroke(path.line_pt(x1, y1, x2, y2), privatedata.lineattrs) -- 2.7.0.341.gc1754cc |