3

I need to create an ocatve script which will generate a 2D-plot and then directly export it as image without actually plotting it.

Hypothetical Example:

x=1:10;
exportDirectly(x,'myImage.jpg');

Is this possible?

clabacchio
  • 1,047
  • 1
  • 17
  • 28
Pantelis Sopasakis
  • 1,902
  • 5
  • 26
  • 45
  • 3
    I think [this](http://stackoverflow.com/q/6289807/572616) question can help. – Woltan Dec 05 '11 at 12:20
  • This answer has a few related techniques: http://stackoverflow.com/questions/7721255/axis-coordinates-to-pixel-coordinates-matlab/7721402#7721402 – reve_etrange Dec 05 '11 at 12:29
  • 1
    I found it: octave:2> f=figure("visible","off"); octave:3> plot([10,1,20,5,24]); octave:4> print("MyPNG.png", "-dpng"); The credit goes to Woltan for pointing out a useful answer! Thanks a million! – Pantelis Sopasakis Dec 05 '11 at 12:43

1 Answers1

0

You can create a figure, but turn of visibility. Then plot and save as usual.

something like

fh = figure()
fh.set('Visible','Off')
%Some Plotting here
print(fh)

That might be of some help...

samirahmed
  • 1,219
  • 2
  • 12
  • 16