Support for Arrows in Plots

53 views
Skip to first unread message

ObsessiveMathsFreak

unread,
Jul 14, 2012, 6:13:47 PM7/14/12
to sage-s...@googlegroups.com
The current support for arrows in sage plots currently isn't very satisfactory. Arrows have odd behaviour, and "fat" heads with no obvious styling options. The following code

arrow2d((0, 0), (2, 3), color="red")+point((2,3))

Generates an arrow, but the head does not reach the required point, and the tail does not touch the origin. I can find no documentation or methods for drawing an arrow which does so.

A related point is the lack of arrow in plot axes. It would be nice to have a simple "Arrows=true" but again this does not seem to be available.

Are there workarounds for these issues, arrows not touching endpoints and arrows on axes? I've tried looking into calling matplotlib directly, but again, I haven't been able to find much in the way of arrow documentation.

Jason Grout

unread,
Jul 14, 2012, 11:56:25 PM7/14/12
to sage-s...@googlegroups.com
On 7/14/12 5:13 PM, ObsessiveMathsFreak wrote:
> The current support for arrows in sage plots currently isn't very
> satisfactory. Arrows have odd behaviour, and "fat" heads with no obvious
> styling options. The following code
>
> arrow2d((0, 0), (2, 3), color="red")+point((2,3))
>
> Generates an arrow, but the head does not reach the required point, and
> the tail does not touch the origin. I can find no documentation or
> methods for drawing an arrow which does so.
>
> A related point is the lack of arrow in plot axes. It would be nice to
> have a simple "Arrows=true" but again this does not seem to be available.

That's right; it's not available as an option. It would be great to add
it! You'd need to look into how to do with matplotlib and add the
necessary code, I think in SAGE_ROOT/devel/sage/sage/plot/graphics.py.


>
> Are there workarounds for these issues, arrows not touching endpoints
> and arrows on axes? I've tried looking into calling matplotlib directly,
> but again, I haven't been able to find much in the way of arrow
> documentation.

http://trac.sagemath.org/sage_trac/ticket/12836 should have fixed the
too-short arrows in 5.1.

Jason

ObsessiveMathsFreak

unread,
Jul 19, 2012, 4:00:17 PM7/19/12
to sage-s...@googlegroups.com
Upgrading to sage 5.1 did indeed fix the arrow issue. A note on this: In 5.1 the default size for images is significantly larger, but this is controllable through figsize.

As it turns out, matplotlib does not support arrows in axes. I cannot fathom why, but it just doesn't unless you rip out the spine based code in graphics.py and replace it with an "aritisaxis" or the like. I'm sorry, but I've given up on trying to get any arrow code to work.


kcrisman

unread,
Jul 19, 2012, 4:13:23 PM7/19/12
to sage-s...@googlegroups.com


On Thursday, July 19, 2012 4:00:17 PM UTC-4, ObsessiveMathsFreak wrote:
Upgrading to sage 5.1 did indeed fix the arrow issue. A note on this: In 5.1 the default size for images is significantly larger, but this is controllable through figsize.


Yes, I've been noticing this all summer with worksheets I've been updating. This may be due to #12213 and friends, though that was merged quite a while ago.  #11915 is also possible.  

I don't know that it's a bug per se, though I have noticed that it's now pretty hard under *default* zoom on most browsers on a laptop to view both the graphic and a lot of accompanying text.  

Thoughts on this, anyone who was involved on some of these tickets?

Jason Grout

unread,
Jul 19, 2012, 4:28:32 PM7/19/12
to sage-s...@googlegroups.com
On 7/19/12 3:13 PM, kcrisman wrote:
>
>
> On Thursday, July 19, 2012 4:00:17 PM UTC-4, ObsessiveMathsFreak wrote:
>
> Upgrading to sage 5.1 did indeed fix the arrow issue. A note on
> this: In 5.1 the default size for images is significantly larger,
> but this is controllable through figsize.
>
>
> Yes, I've been noticing this all summer with worksheets I've been
> updating. This may be due to #12213 and friends, though that was merged
> quite a while ago. #11915 is also possible.
>
> I don't know that it's a bug per se, though I have noticed that it's now
> pretty hard under *default* zoom on most browsers on a laptop to view
> both the graphic and a lot of accompanying text.
>
> Thoughts on this, anyone who was involved on some of these tickets?

It's pretty straightforward to change the default image size back.
Indeed, it may be better to change it back; you guys aren't the first to
complain.

Jason


kcrisman

unread,
Jul 19, 2012, 4:44:20 PM7/19/12
to sage-s...@googlegroups.com
Oh, so it did change?  What line?  (I'm sure I could eventually find this...) 

Jason Grout

unread,
Jul 19, 2012, 4:52:42 PM7/19/12
to sage-s...@googlegroups.com
See
https://github.com/sagemath/sagelib/blob/master/sage/plot/plot.py#L335
and the commits that touched that line.

Jason



Jason Grout

unread,
Jul 19, 2012, 4:55:47 PM7/19/12
to sage-s...@googlegroups.com
On 7/19/12 3:52 PM, Jason Grout wrote:

>>
>> Oh, so it did change? What line? (I'm sure I could eventually find
>> this...)
>
> See
> https://github.com/sagemath/sagelib/blob/master/sage/plot/plot.py#L335
> and the commits that touched that line.

In particular, look where DEFAULT_FIGSIZE was used in this commit:

https://github.com/sagemath/sagelib/commit/aa1be58ca6d2bc1e733dffc9c145f13dffca7244

(I think I made this commit, but you are the author since you rebased it).

Jason



Reply all
Reply to author
Forward
0 new messages