On Mar 4, 7:54 pm, Jonathan Bober <jwbo...@gmail.com> wrote:
> Sometimes I plot a function that takes a long time to compute:
>
> P = plot(f, 0, 10) # (wait a long time)
>
> and then I decide that, oops, I wanted that plot to be red, or I wanted
> the lines to be dashed, or...
>
> So then I make a new plot by typing
>
> P = plot(f, 0, 10, rgbcolor=(1, 0, 0)) # (wait a long time again)
>
> Is there a way to change the color, or change the line type, etc.
> without recalculating the plot (and waiting a long time again)?

Short answer: yes.

Long answer: Depending on what you want to do, probably you would have
to ask matplotlib directly to change it.   There are numerous
exceptions, but I don't know that the thing you specifically asked for
is one of them.

Example:


sage: P = plot(x,0,10,color='blue')
sage: P.tick_label_color((1,0,0))
sage: P # red tick labels
sage: P.tick_label_color((1,1,0))
sage: P # yellow tick labels

sage: p = P[0]  # gets the line's graphics primitive
sage: p
Line defined by 200 points
sage: p.set_options(rgbcolor='yellow') # this would be nice to work,
but doesn't as far as I know, nor anything similar

Instead, here is what actually does work... and let me tell you, you
didn't want to do the trial and error morass of default option seeking
I just did to find this.


sage: D = line2d.options  # this is a dictionary of default options
sage: D
{'alpha': 1, 'legend_label': None, 'rgbcolor': (0, 0, 1), 'thickness':
1}
sage: D['rgbcolor'] = 'yellow'
sage: p.__init__(p.xdata,p.ydata,D)
sage: P # yellow plot!

However, I have no idea if this would speed things up.  At any rate,
the xdata and ydata has already been calculated, so if that is the
bottleneck, this sort of thing could help you.  Nothing will make
matplotlib generate the picture faster, though.

- kcrisman

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to