How add axes labels and titles to Sage plots?

1,802 views
Skip to first unread message

sebe...@spawar.navy.mil

unread,
Oct 4, 2008, 6:21:27 PM10/4/08
to sage-support
Call me stupid but I've looked at lots of Sage plot examples and docs.
I can't seem to find an example that labels the axes or adds a title
to a plot!?

I know that Sage is based on Matplotlib yet uses Mathematica plot
syntax.

I've tried guessing it but haven't nailed it yet.

Where find this info?

Thanks!

Chris

sebe...@spawar.navy.mil

unread,
Oct 4, 2008, 6:21:27 PM10/4/08
to sage-support

David Joyner

unread,
Oct 4, 2008, 8:10:02 PM10/4/08
to sage-s...@googlegroups.com

You can find an example for adding text to a 2d-plot at
http://www.sagemath.org/doc/tut/node18.html
or type
sage: text?
at the command line.


>
> Thanks!
>
> Chris
>
> >
>

sebe...@spawar.navy.mil

unread,
Oct 5, 2008, 12:44:44 AM10/5/08
to sage-support
On Oct 4, 5:10 pm, "David Joyner" <wdjoy...@gmail.com> wrote:
> type
> sage: text?
> at the command line.

Yes thank you. I'm aware of text(..) but it is more low level than
necessary for axes labels and plot titles.....This is because the user
has to provide the position rather than software figuring it out for
you. I just thought I was missing something.

Thanks again.

Chris

Martin Albrecht

unread,
Oct 5, 2008, 7:35:32 AM10/5/08
to sage-s...@googlegroups.com
On Sunday 05 October 2008, sebe...@spawar.navy.mil wrote:
> Yes thank you. I'm aware of text(..) but it is more low level than
> necessary for axes labels and plot titles.....This is because the user
> has to provide the position rather than software figuring it out for
> you. I just thought I was missing something.

AFAIK this is just not implemented (yet). It should be relatively easy as
matplotlib supports it. Volunteers?

Cheers,
Martin

--
name: Martin Albrecht
_pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
_www: http://www.informatik.uni-bremen.de/~malb
_jab: martinr...@jabber.ccc.de

sebe...@spawar.navy.mil

unread,
Oct 5, 2008, 1:03:12 PM10/5/08
to sage-support
I'd be willing to try. Let me contact you by another email address.

Chris

On Oct 5, 4:35 am, Martin Albrecht <m...@informatik.uni-bremen.de>
wrote:
> _jab: martinralbre...@jabber.ccc.de

Martin Albrecht

unread,
Oct 5, 2008, 1:18:57 PM10/5/08
to sage-s...@googlegroups.com
On Sunday 05 October 2008, sebe...@spawar.navy.mil wrote:
> I'd be willing to try. Let me contact you by another email address.
>
> Chris
>
> On Oct 5, 4:35 am, Martin Albrecht <m...@informatik.uni-bremen.de>
>
> wrote:
> > On Sunday 05 October 2008, seber...@spawar.navy.mil wrote:
> > > Yes thank you.  I'm aware of text(..) but it is more low level than
> > > necessary for axes labels and plot titles.....This is because the user
> > > has to provide the position rather than software figuring it out for
> > > you.  I just thought I was missing something.
> >
> > AFAIK this is just not implemented (yet). It should be relatively easy as
> > matplotlib supports it. Volunteers?

As it turns out, my comment was wrong. This works:

sage: p = plot(sin,-pi,pi)
sage: p.axes_labels(['foo','bar'])
sage: p.show()

Cheers,
Martin

_jab: martinr...@jabber.ccc.de

Stan Schymanski

unread,
Oct 6, 2008, 4:26:18 AM10/6/08
to sage-support
As far as I know, the title function is not implemented in plot yet.
It would also be very useful to have a legend function similar to the
one in pylab. There has been a discussion of this on the support list
already, and I concluded that someone might be working on the plot
functionalities already. Just search the support list for "legend".
I use pylab from within Sage for any more sophisticated plotting. It
works great. It would be nice if the Sage plot function would take all
the options of pylab plots. No idea how hard it would be to implement
it.

Stan

On Oct 5, 7:18 pm, Martin Albrecht <m...@informatik.uni-bremen.de>
wrote:
>
> As it turns out, my comment was wrong. This works:
>
> sage: p = plot(sin,-pi,pi)
> sage: p.axes_labels(['foo','bar'])
> sage: p.show()
>
> Cheers,
> Martin
>
> --
> name: Martin Albrecht
> _pgp:http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
> _www:http://www.informatik.uni-bremen.de/~malb
> _jab: martinralbre...@jabber.ccc.de

William Stein

unread,
Oct 6, 2008, 12:51:27 PM10/6/08
to sage-s...@googlegroups.com, Mike Hansen, emily kirkman
On Mon, Oct 6, 2008 at 1:26 AM, Stan Schymanski <schy...@gmail.com> wrote:
>
> As far as I know, the title function is not implemented in plot yet.
> It would also be very useful to have a legend function similar to the
> one in pylab. There has been a discussion of this on the support list
> already, and I concluded that someone might be working on the plot
> functionalities already.

To the best of my knowledge at present absolutely nobody is
working in a concerted way on 2d or 3d plotting in Sage right now.
Mike Hansen did a lot of useful cleanup, but has moved onto
sphinx-ify the documentation, which is higher priority.
I had hoped Emily Kirkman would work on plotting this summer,
and after, but she has ended up working on different things.
I had also hoped something longterm regarding plotting would
come out of Sage Days 9, but that didn't happen due to the
organization of that meeting.

I'll keep my eyes open for a student to hire at UW to work
on plotting, but so far I don't know of anybody qualified
and interested yet.

-- William

> Just search the support list for "legend".
> I use pylab from within Sage for any more sophisticated plotting. It
> works great. It would be nice if the Sage plot function would take all
> the options of pylab plots. No idea how hard it would be to implement
> it.
>
> Stan
>
> On Oct 5, 7:18 pm, Martin Albrecht <m...@informatik.uni-bremen.de>
> wrote:
>>
>> As it turns out, my comment was wrong. This works:
>>
>> sage: p = plot(sin,-pi,pi)
>> sage: p.axes_labels(['foo','bar'])
>> sage: p.show()
>>
>> Cheers,
>> Martin
>>
>> --
>> name: Martin Albrecht
>> _pgp:http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
>> _www:http://www.informatik.uni-bremen.de/~malb
>> _jab: martinralbre...@jabber.ccc.de
> >
>

--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

Jason Grout

unread,
Oct 6, 2008, 1:17:12 PM10/6/08
to sage-s...@googlegroups.com
William Stein wrote:
> On Mon, Oct 6, 2008 at 1:26 AM, Stan Schymanski <schy...@gmail.com> wrote:
>> As far as I know, the title function is not implemented in plot yet.
>> It would also be very useful to have a legend function similar to the
>> one in pylab. There has been a discussion of this on the support list
>> already, and I concluded that someone might be working on the plot
>> functionalities already.
>
> To the best of my knowledge at present absolutely nobody is
> working in a concerted way on 2d or 3d plotting in Sage right now.
> Mike Hansen did a lot of useful cleanup, but has moved onto
> sphinx-ify the documentation, which is higher priority.
> I had hoped Emily Kirkman would work on plotting this summer,
> and after, but she has ended up working on different things.
> I had also hoped something longterm regarding plotting would
> come out of Sage Days 9, but that didn't happen due to the
> organization of that meeting.
>
> I'll keep my eyes open for a student to hire at UW to work
> on plotting, but so far I don't know of anybody qualified
> and interested yet.

Gee, I wish I was a student at UW! :). I really appreciate the effort
various people have put into the plotting framework. The NotImplemented
parts have bothered me for a while (as well as some of the framework
itself), but I haven't had time to do an overhaul, though I've made some
somewhat meager attempts at starting. If someone were to spearhead such
a thing, I'd like to be involved. I don't see the time in my future for
spearheading such a thing until possibly next April/May at the earliest.

Mike's improvements to plot.py (both his cleanup and his patch for
options decorators) make such an overhaul much easier. Kudos and a
candy bar to him.

Thanks,

Jason

Reply all
Reply to author
Forward
0 new messages