print png figure terminal mode remotely

4 次查看(过去 30 天)
Hello everybody
I am facing a problem in matlab because I am trying to scatter3 plot a great amount of figures. So, I decided to give a try via a unix terminal in a cluster instead of a small computer.
However, if I try
matlab -r -nodesktop "instructions;" &
in which the script instructions.m looks like this:
scatter3(x0,y0,z0, '.');
print ('-dpng', 'name0.png')
scatter3(x1,y1,z1, '.');
print ('-dpng', 'name1.png')
scatter3(x2,y2,z2, '.');
print ('-dpng', 'name2.png')
.
etc up to 10000
.
Then, the png are never created because the print function takes a great deal of time making it unefficient.
I have read to try hgsave or saveas but that didn't work either.
I know that if I ssh log in with x11 active then it works but I need to do it without the x11 active.
Could someone please bring me some light in this?
Thank you in advance.

回答(1 个)

Surya Talluri
Surya Talluri 2020-8-7
I understand that you are trying to display every scatter plot and then print it.
You can tun off figure visibility and then save the figure. In this way as you are not trying to show any plot GUI, there is no need to enable X11 forwarding and you can directly save the plot.
f = figure('visible','off');
scatter3(x0,y0,z0, '.');
saveas(f,'name0.png')
f = figure('visible','off');
scatter3(x1,y1,z1, '.');
saveas(f,'name1.png')
  1 个评论
Walter Roberson
Walter Roberson 2020-8-7
That figure() command needs to make the figure visible momentarily and then sets it to not visible. Whether you observe a flash or not as the window appears and disappears depends on your system, and the timing, and your window manager.
There are some internal calculations and settings that are postponed until the figure is made visible. If there is any internal call to trigger those calculations and settings without making the figure visible, then I have not been able to find it.
For example the Extent property of a uicontrol is garbage until the control is rendered by the figure being made visible. (You need the Extent to be valid if you are trying to find out the size that some text renders as because you are trying to dynamically size a control to just large enough to include the text. The size cannot be easily computed because it depends on the display resolution and on the font and the content of the text, remembering proportional fonts and kerning.) The only way to get some information is to set the figure visible to trigger the size calculations, then set the figure invisible again. Most of the time you will not see the flash at all, but sometimes you do...

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by