Create and save figure without drawing

조회 수: 10 (최근 30일)
Gabriel Stanley
Gabriel Stanley 2022년 9월 24일
댓글: Gabriel Stanley 2022년 9월 26일
I would like to create figures within a script without actually drawing them, on the assumption that this will save time, RAM, and GPU resources. I would like to save those objects as pictures. However, each figure is a layering of two different datasets. In an interactive setting I would achieve this through the hold on command
A = randi(9,1,15);
B = randi(9,1,15);
MyScatter = scatter([1:15],A)
hold on
MyScatter = scatter([1:15],B)
But this still creates a figure window and draws the objects to the screen.
Is there a way to do what I describe, perhaps via copyobj? And/or am I unlikely to see significant computational savings by doing so?

채택된 답변

Mahdi Hayati
Mahdi Hayati 2022년 9월 24일
To save figure as picture in your system, without actually showing the figure, first make your figure invisible:
f = figure('visible','off');
then go for your scatter and add them to the ' f ' which is your invisible figure.
finally you can use saveas function to save the figure as picture.
  댓글 수: 3
Walter Roberson
Walter Roberson 2022년 9월 26일
Layout will not always work until the object is rendered. For example tick labels might not be correct if adding an additional component resized an axes (resizing can affect number of ticks generated)
Gabriel Stanley
Gabriel Stanley 2022년 9월 26일
Understood, and thank you for the warning. I had been going to preallocate/define the axes properties of the scatter plot, but It's very late where I am and for reasons I haven't had time to run down,
MyFigure = figure('visibile','off')
MyAxes= axes(MyFigure,%Various Name/Value pairs)
Was thowing an error indicating MyFigure wasn't an appropriate handle. If I notice any significant problem while putting the scatterplots into my report, I'll remember this and see about debugging the handle issue.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by