Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 10 years ago

calc314 gravatar image

You can print to a file from the terminal using the print command. For example,

x=0:0.1:10
figure()
plot(sin(x))
print('~/sine.jpg')
click to hide/show revision 2
No.2 Revision

You can print to a file from the terminal using the print command and then open the jpg file in SMC using the open command via Octave's system command. For example,Here is my .m file:

x=0:0.1:10
figure()
plot(sin(x))
print('~/sine.jpg')
x=0:0.1:10;
figure();
plot(sin(x));
print('~/sine.jpg');
system('open sine.jpg');

This will pop open the graph in a new tab within SMC.

click to hide/show revision 3
No.3 Revision

You can print to a file from Octave in the terminal using the print command and then open the jpg file in SMC using the open command via Octave's system command. Here is my .m file:

x=0:0.1:10;
figure();
plot(sin(x));
print('~/sine.jpg');
system('open sine.jpg');

This will pop open the graph in a new tab within SMC.

If you are working from within a worksheet in SMC, you can get the graph to display within the worksheet by using:

%octave
x = 0:0.1:10;
h = figure('visible', 'off');
plot(sin(x));
saveas(h,"~/fig.png");
%sage salvus.file("fig.png")