Spurious legend item

32 views
Skip to first unread message

Nicolas Mascot

unread,
Jun 16, 2015, 6:18:52 AM6/16/15
to sage-s...@googlegroups.com
Dear Sage support team,

I am puzzled at this:

E=EllipticCurve([1.6,0.3])
X=plot([])
X+=E.plot(color="green",legend_label=str(exp(1.)))
X

works fine (the legend is ok), but when I do

Qx.<x>=PolynomialRing(QQ)
K.<a> = NumberField(x^2-2)
S = K.embeddings(RR)
E=EllipticCurve([a,0])
X=plot([])
X+=E.base_extend(S[0]).plot(color="red",legend_label=str(exp(1.)))
X

the legend appears twice (tried with 6.4.1, 6.6, 6.7). Is it a bug ?

Best regards,
Nicolas Mascot

kcrisman

unread,
Jun 16, 2015, 8:30:08 AM6/16/15
to sage-s...@googlegroups.com, legrand...@gmail.com
This is indeed odd.
 
X=plot([])

You shouldn't have to do this - let us know if it doesn't plot otherwise.  And the canonical way to do it if you really wanted to is X = Graphics() . 
 
X+=E.base_extend(S[0]).plot(color="red",legend_label=str(exp(1.)))
X

the legend appears twice (tried with 6.4.1, 6.6, 6.7). Is it a bug ?

I would think so.

sage: F = E.base_extend(S[0])
sage: F.plot(legend_label='b')
Launched png viewer for Graphics object consisting of 2 graphics primitives

So note that it really is two objects.

sage: F.plot()
Launched png viewer for Graphics object consisting of 2 graphics primitives

And it is even without the label!  That just makes it obvious.  In fact, this is even documented (!)

            sage: E = EllipticCurve('37a')
            sage: plot(E)
            Graphics object consisting of 2 graphics primitives

So the question is what to do about it with things like legends.  The code for plotting is very ugly, presumably to take care of the 'bounded' and 'unbounded' components, but I did find where it comes in.

        for j in range(len(I)):
            <snip>
            if shape == 'o':
                g += plot.line(v + list(reversed(w)) + [v[0]], **args)
            elif shape == '<':
                g += plot.line(list(reversed(v)) + w, **args)
            elif shape == '>':
                g += plot.line(v + list(reversed(w)), **args)
            else:
                g += plot.line(v, **args)
                g += plot.line(w, **args)
        return g

So *each* component gets all optional arguments.  Which ordinarily makes sense (things like color or F.plot(marker='^') or F.plot(linestyle='--')) but in this case does not.

I've opened http://trac.sagemath.org/ticket/18711 but I would appreciate if any number theorists could comment there what they expect and so forth, because one wouldn't want some nasty side effects from anything done.  One could monkey in a solution for legend stuff but in truth there are a lot of legend options and so it would be better to have a cleaner solution, such as one that did the plots first and *then* passed in keyword arguments, if that were possible.

- kcrisman

John Cremona

unread,
Jun 16, 2015, 11:22:34 AM6/16/15
to SAGE support, Nicolas Mascot
Thanks for the helpful suggestions. I am not sure who wrote the
plotting funtion, but it goes back to the early days of Sage. I have
a feeling that David Roe most recently worked on it, and if so then we
might be able to fix it at the upcoming LMFDB workshop when he, and
Nicolas and I will be there.

John
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support...@googlegroups.com.
> To post to this group, send email to sage-s...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.

kcrisman

unread,
Jun 17, 2015, 8:47:35 AM6/17/15
to sage-s...@googlegroups.com, john.c...@gmail.com, legrand...@gmail.com
Thanks for the helpful suggestions. I am not sure who wrote the
plotting funtion, but it goes back to the early days of Sage.  I have
a feeling that David Roe most recently worked on it, and if so then we
might be able to fix it at the upcoming LMFDB workshop when he, and
Nicolas and I will be there.



That would be great.  I'll note that it could be worth trying the Sage implicit plot on it, since that seems to be about what is tried here - maybe the elliptic curve plot implementation predates that function?
Reply all
Reply to author
Forward
0 new messages