set_legend_options and set_aspect_ratio don't seem to do anything

43 views
Skip to first unread message

Dan Drake

unread,
Nov 15, 2011, 11:44:19 PM11/15/11
to sage-devel
It seems that I've discovered more broken things in the plotting code!

I'm trying to get my plots to look right, and I've discovered that I
can't alter the legend or aspect ratio with the relevant "set_" functions:

sage: q = plot(tan(x), (x,-1,1))
sage: q.set_aspect_ratio(5)

...which has no affect on q. Likewise:

sage: q = plot(tan(x), (x,-1,1))
sage: q.set_legend_options(title='tangent!')

does nothing. Am I doing something wrong? Have I found some bugs?

Dan

--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------

signature.asc

Jason Grout

unread,
Nov 16, 2011, 7:51:05 AM11/16/11
to sage-...@googlegroups.com
On 11/15/11 10:44 PM, Dan Drake wrote:
> It seems that I've discovered more broken things in the plotting code!
>
> I'm trying to get my plots to look right, and I've discovered that I
> can't alter the legend or aspect ratio with the relevant "set_" functions:
>
> sage: q = plot(tan(x), (x,-1,1))
> sage: q.set_aspect_ratio(5)
>
> ...which has no affect on q.


This is fixed in #11963 (needs review! :)


Likewise:
>
> sage: q = plot(tan(x), (x,-1,1))
> sage: q.set_legend_options(title='tangent!')
>
> does nothing. Am I doing something wrong? Have I found some bugs?

I don't know about this. It would be something to look into. It might
be better to just have a function to set the show options for a figure,
rather than specific setter functions for each possible show option.
Something like:

q.set_show_options(legend_label='tangent')

which would be the same as:

plot(tan(x), (x,-1,1),legend_label='tangent')

Jason


kcrisman

unread,
Nov 16, 2011, 8:34:31 AM11/16/11
to sage-devel

> > sage: q = plot(tan(x), (x,-1,1))
> > sage: q.set_legend_options(title='tangent!')
>
> > does nothing. Am I doing something wrong? Have I found some bugs?
>
> I don't know about this.  It would be something to look into.  It might

Not exactly a bug. You have to actually have a function with legend
first to do anything with it. The title is referring to the title of
the box with the legends.


sage: p = plot(tan(x),-1,1,legend_label='Tangent!')
sage: p # legend for this func
sage: p.set_legend_options(title='Mine')
sage: p # title to the box
sage: p += plot(-tan(x),-1,1,legend_label='Neg.Tan!')
sage: p # both functions in legend - notice the title is gone, perhaps
this is a bug in addition of plots
sage: p.set_legend_options(title='Mine')
sage: p # now the title to the box is back

Dan and Jason, what do you think the bug here is? It seems like at
least the addition thing is. But having a title to an empty legend
box seems silly.

- kcrisman

Dan Drake

unread,
Nov 16, 2011, 8:45:09 AM11/16/11
to sage-...@googlegroups.com
On Wed, 16 Nov 2011 at 06:51AM -0600, Jason Grout wrote:
> This is fixed in #11963 (needs review! :)

I looked over your patch and it seems good. I'll check it out tomorrow
morning when I'm at my work computer.

> Likewise:
> >
> >sage: q = plot(tan(x), (x,-1,1))
> >sage: q.set_legend_options(title='tangent!')
> >
> >does nothing. Am I doing something wrong? Have I found some bugs?
>
> I don't know about this. It would be something to look into. It
> might be better to just have a function to set the show options for
> a figure, rather than specific setter functions for each possible
> show option. Something like:
>
> q.set_show_options(legend_label='tangent')
>
> which would be the same as:
>
> plot(tan(x), (x,-1,1),legend_label='tangent')

That could be convenient. I'm producing my plots in one function and
showing them in another, so it's nice to be able to alter things after
the "production" step.

signature.asc

kcrisman

unread,
Nov 16, 2011, 9:01:14 AM11/16/11
to sage-devel

> > q.set_show_options(legend_label='tangent')
>
> > which would be the same as:
>
> > plot(tan(x), (x,-1,1),legend_label='tangent')
>
> That could be convenient. I'm producing my plots in one function and
> showing them in another, so it's nice to be able to alter things after
> the "production" step.

Agreed. However, I don't think this should replace the current
things, which allow for some nice fine-grained control without using
big hammers.

Dan Drake

unread,
Nov 16, 2011, 11:17:57 PM11/16/11
to sage-...@googlegroups.com
On Wed, 16 Nov 2011 at 06:51AM -0600, Jason Grout wrote:
> This is fixed in #11963 (needs review! :)

Now has a positive review. Thanks for fixing that part of my problem!

By the way, my recent flurry of complaints about various plotting things
are all related to this worksheet that I've been working on to
demonstrate complex contour integration:

https://sagenb.kaist.ac.kr:8066/home/pub/46/

signature.asc
Reply all
Reply to author
Forward
0 new messages