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!
Jose.
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!
Jose.
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')
The above example depends on a function f being defined, e.g.,
x = var('x')
f(x) = sin(3*x)*x+log(x) + 1/(x+1)^2
Yes. In fact, the ability to look at the code is one of the main
reasons for Sage's existence! The code for plotting is in the directory:
$SAGE_ROOT/devel/sage/sage/plot/
where $SAGE_ROOT is the directory that contains the sage binary.
Thanks,
Jason