On Wed, Apr 15, 2009 at 10:37 AM, Jose Guzman <[email protected]> wrote:
>
> William Stein wrote:
>> 2009/4/15 William Stein <[email protected]>:
>>
>>> 2009/4/15 Jose Guzman <[email protected]>:
>>>
>>>> Hi there
>>>>
>>>> I am trying to teach some simple principles of single compartment models
>>>> with sage and I plotted a couple of exponential equations in my notebook.
>>>>
>>>> Although I got a nice x-axis () and other labels and similar things, I
>>>> cannot find a way to plot the y-axis in the vertical axis. Is there
>>>> anyway to do it?
>>>>
>>>> You can take a look to my notebook to see what I mean
>>>> http://sagenb.org/home/pub/457
>>>>
>>>> Another additional problem is that the LaTeX fonts are pretty small, and
>>>> I cannot represent Greek letters (like alpha, tau, pi,etc..) in the
>>>> labels (see the syntax bellow).
>>>>
>>>> xlabel = text('Time (Units of $\tau$)',(3,-.10), rgbcolor='black')
>>>>
>>>> This \tau does not show up in the graphic, but strange enough, this
>>>> works out of the box (pretty small though)
>>>>
>>>> lnlabel = text('Unrecoverable fraction ($f_{U} = 1 -
>>>> f_{S}$)',(4,FS+.05),rgbcolor='black')
>>>>
>>>> thank you very much in advance for your help and care!
>>>>
>>> Just one remar. There is a fontsize option to text:
>>>
>>>
>>> xlabel = text('Time (Units of $\tau$)',(3,-.10), rgbcolor='black',
>>> fontsize=30)
>>>
>>> William
>>>
>>
>> The second remark is that backslash is an escape character for strings in
>> (almost) all programming languages. You have to do \\ to get a single
>> backslash, so this works:
>>
>> xlabel = text('Time (Units of $\\tau$)',(3,-.10), rgbcolor='black',
>> fontsize=30)
>>
>> Or you can do:
>>
>> xlabel = text(r'Time (Units of $\tau$)',(3,-.10), rgbcolor='black',
>> fontsize=30)
>>
>>
> Thank you very much for your remarks, everything worked fine, except for
> that I did not manage to create a vertical oriented y-axis label.
That might not be implemented yet in Sage directly.
> I
> think the solution would be to import the matplotlib python module and
> use it under Sage, however I did not find a proper manual to follow.
Here is how to use matplotlib directly in the Sage notebook:
import pylab as p
p.figure()
t = p.arange(0.01, 2.0, 0.01)
s = p.sin(2 * p.pi * t)
s = p.array([float(f(x)) for x in t])
P = p.plot(t, s, linewidth=4)
p.xlabel('time (s)'); p.ylabel('voltage (mV)')
p.title('Matlab-style plotting in Sage')
p.grid(True)
p.savefig('sage.png')
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---