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 开发者_如何学Gowill 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 :)
That is a known bug : A question I asked long time ago in Matlab Central forums
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...
精彩评论