cloud icon indicating copy to clipboard operation
cloud copied to clipboard

make it so plotting from octave worksheets... just works

Open williamstein opened this issue 11 years ago • 1 comments

Requested by Heather Van Dyke.

I'll do this in much the same way I made plotting just work for R worksheets. The key idea is illustrate by the following:

ONE. Run this code in a new Sage Worksheet before running octave.

os.environ['GNUTERM']='svg'
def octave_plot():
    _=octave.eval("print /%s/.tmp.svg"%os.path.abspath('.'))
    salvus.file('.tmp.svg')

TWO. Run this code in a cell to draw an Octave plot:

%octave
clf()
x = -10:0.1:2;
plot (x, sin(x))

THREE. Now type octave_plot() in a cell to render the current octave plot!

screen shot 2014-02-13 at 9 13 56 am

williamstein avatar Feb 13 '14 17:02 williamstein

I also want to point out how -- right now -- one can use Octave in a terminal with graphics and for editing files. These illustrate how SageMathCloud already has all the tools needed to build a standard matlab-style web-based UI around Octave -- the actual . Right now you can simulate such a thing by opening three browser windows at once.

ONE: Create a new terminal by clicking "+New --> Terminal".

TWO: Run octave like this:

GNUTERM=svg octave

THREE: create and save a plot

octave:1> fplot (@sin, [-10, 100]);
octave:2> print a.svg;

FOUR: Click files in the upper left, then click on the file "a.svg" to see the plot. When you change you it you can refresh it. You can also copy/paste the link to open it in another browser window.

FIVE: You can also edit a file such as foo.m (use +New --> "foo.m" [File]), with proper syntax highlighting, auto-indent, etc. When you want to read in the code from there to the terminal, you can source foo.m.

screen shot 2014-02-13 at 9 28 47 am

williamstein avatar Feb 13 '14 17:02 williamstein