I am using Sage version 3.4 running on Linux/Debian. I am still not very
familiar with Sage though. I tried to plot the following equation:
sage: var('t'); # symbolic variable
sage: var('g'); # symbolic variable
sage: f(t) = g*(t**2-1)/(2*(t-1)) # try to simplify this function later...
Obviously the function is not defined at t=1. Returns (0/0)
sage: f(1).subs(g=9.81) # returns Division by 0
The problem comes when I try to plot the whole function f(t). By default
the plot is between -1 and +1.
sage: fig = plot(f.subs(g=9.81)) # substitute g by 9.81 , otherwise not
plotted
sage: show(fig)
even If I try to plot between the t=1 and t=10.
sage: show(fig,xmin=1,xmax=10)
The function is not plotted above x>1. . Is there any way to plot this
function above xmin=1?
Thank you very much in advance for your help
Jose.
> Yes it works! for some strange reason it did not work in my old sheet. I
> though to plot one should use a combination of plot() and show()
> commands. Actually, I created a small tutorial for private use to learn
> more about sage commands to plot, which talks about the use of plot()
> and show(). I expected to use it for my future curse of Sage for
> scientist in my institute. :P You can see in http://sagenb.org/home/pub/399
This looks great. Would you be willing to contribute it to Sage as a
"primer"? (A Sage primer is a short, focused exploration of a specific
functionality of Sage.)
Jason
> Yes it works! for some strange reason it did not work in my old sheet. I
> though to plot one should use a combination of plot() and show()
> commands. Actually, I created a small tutorial for private use to learn
> more about sage commands to plot, which talks about the use of plot()
> and show(). I expected to use it for my future curse of Sage for
> scientist in my institute. :P You can see in http://sagenb.org/home/pub/399
In looking at your code, I had an idea about specifying colors. Why
don't we have some default color objects defined in Sage, like red,
blue, yellow, green, etc. Methods could include .darker(), .lighter(),
etc. So you could specify a plot as:
plot(x^2, (x,0,1), color=red)
plot(x^3, (x,0,1), color=blue.darker())
plot(x^4, (x,0,1), color=green.lighter())
plot(x^5, (x,0,1), color=red+blue) #gives purple :)
and then for the more esoteric names (all of the standard web colors,
all of the standard x11 colors, etc.), use the color namespace.
plot(sin(x), (x,0,1), color=color.goldenrod)
Thoughts?
Jason
I would be happy to contribute to any form with the
development/expansion of Sage :D. Feel free to use this document.
However, somebody would have to check it just before publishing. The
document is only a very short introduction, I was planning to add some
other features (ie. plot_list() ) and the 3D plotting capabilities of Sage.
You may want to have a look to the other worksheet I published online
about limit calculations, just enter: http://sagenb.org/home/pub/398/
As I commented before, I am planning to do a series of basic
documentation of that type related with Sage for scientific purposes.
Feel free to contact me any time.
Jose.
Yes, I'm saying that in addition to being able to pass a tuple or
string, we'd be able to pass a sage color object.
Jason
That's a great idea, which is why I implemented it over a year ago :-)
sage: C = Color('red') # a Sage color object
sage: C
RGB color (1.0, 0.0, 0.0)
sage: C.html_color()
'#ff0000'
sage: plot(x^2, (x,0,1), color=C)
I think the only strings allowed in the Color constructor are:
"red" : (1.0,0.0,0.0),
"orange": (1.0,.5,0.0),
"yellow": (1.0,1.0,0.0),
"green" : (0.0,1.0,0.0),
"blue" : (0.0,0.0,1.0),
"purple": (.5,0.0,1.0),
"white" : (1.0,1.0,1.0),
"black" : (0.0,0.0,0.0),
"grey" : (.5,.5,.5)
You can also use any html color strings.
To give the functionality you want, you could add methods "lighter()"
and "darker()" to the existing color object.
William
So how about:
* predefining a bunch of colors in the global namespace (maybe just what
is available in the current strings?)
* predefining a huge number of colors, but sticking them in the colors
namespace
* making some nicely matched color sets (color schemes, if you will).
* make a generic mixing function (which takes the weighted average of
self and other, according to a specifiable fraction)
* make darker/lighter functions
* adding together colors averages them
* a linear combination takes a weighted average (hmmm...have to think
about how to do this one...maybe it'd make more sense to do a different
average?)
Here is what MMA does with colors:
http://reference.wolfram.com/mathematica/guide/Colors.html
Sounds like a great get-your-feet-wet student project...
Jason
I like all your comments but this one--the global namespace is huge
enough as it is. Also, colors.* gives nice tab completion, etc. I
could be OK with the limited set defined above.
> * predefining a huge number of colors, but sticking them in the colors
> namespace
> * making some nicely matched color sets (color schemes, if you will).
> * make a generic mixing function (which takes the weighted average of
> self and other, according to a specifiable fraction)
> * make darker/lighter functions
> * adding together colors averages them
> * a linear combination takes a weighted average (hmmm...have to think
> about how to do this one...maybe it'd make more sense to do a
> different
> average?)
>
> Here is what MMA does with colors:
> http://reference.wolfram.com/mathematica/guide/Colors.html
+1. As well as rgb, we should offer hsb, hsv ways of constructing
colors.
- Robert
>>
>> * predefining a bunch of colors in the global namespace (maybe just
>> what
>> is available in the current strings?)
>
> I like all your comments but this one--the global namespace is huge
> enough as it is. Also, colors.* gives nice tab completion, etc. I
> could be OK with the limited set defined above.
>
>> * predefining a huge number of colors, but sticking them in the colors
>> namespace
>> * making some nicely matched color sets (color schemes, if you will).
>> * make a generic mixing function (which takes the weighted average of
>> self and other, according to a specifiable fraction)
>> * make darker/lighter functions
>> * adding together colors averages them
>> * a linear combination takes a weighted average (hmmm...have to think
>> about how to do this one...maybe it'd make more sense to do a
>> different
>> average?)
>>
>> Here is what MMA does with colors:
>> http://reference.wolfram.com/mathematica/guide/Colors.html
>
> +1. As well as rgb, we should offer hsb, hsv ways of constructing
> colors.
Okay, see:
http://trac.sagemath.org/sage_trac/ticket/5601
http://trac.sagemath.org/sage_trac/ticket/5602
http://trac.sagemath.org/sage_trac/ticket/5603
http://trac.sagemath.org/sage_trac/ticket/5604
http://trac.sagemath.org/sage_trac/ticket/5605
If anyone wants to do these, feel free!
Jason