1

The following code produces a plot and a table on an invisible figure.

 f = figure('Visible','off')
 plot(rand(10),rand(10))
 t = uitable('Parent',f,'Data',rand(10,10))
 saveas(f,'file.jpg','jpg')

The only problem is, that the table will not get printed/saved to a file, I have tried to use print as well to verify it. Neither does the order in which I put plot and uitable matter.

Is there a workaround for this? The reason why I want this to work is, that I would like to save hundreds of plots + table next to it to files and do not want to draw them, as it seems to take some time, although it is just plotting.

The following code will then show the figure, and after that the table magically appears on the print as well.

set(f,'Visible','on')

This is always reproducible so far, I am running R2011a. Thanks :)

Robert Seifert
  • 25,078
  • 11
  • 68
  • 113
aXon
  • 125
  • 1
  • 1
  • 10
  • 2
    it seems to be working for me fine on R2010b. though I have to use `plot` instead of `Plot`. – YetAnotherUser May 20 '11 at 16:23
  • YetAnotherUser has a point. Plot should be lowercase. R2011a, works after that correction. – Rasman May 20 '11 at 17:19
  • I know that plot is lower case and it is a typo in the code. What I am looking for is saving a uitable and plot in a figure, whilst it is invisible, as soon as I make it visible it works, but that is not the desired outcome/way. – aXon May 20 '11 at 18:38

2 Answers2

0

That is a known bug : A question I asked long time ago in Matlab Central forums

Andrey Rubshtein
  • 20,795
  • 11
  • 69
  • 104
0

It is stated in the PRINT function documentation (which SAVEAS calls) that:

If you print or export in nodisplay mode, none of the uicontrols the figure has will be visible. If you run code that adds uicontrols to a figure when the figure is invisible, the controls will not print until the figure is made visible.

So it's not really a bug, more of a limitation...

Amro
  • 123,847
  • 25
  • 243
  • 454