Is there a way to change the active figure without making it visible?

110 ビュー (過去 30 日間)
Will Donahue
Will Donahue 2015 年 4 月 5 日
回答済み: Geoff Hayes 2015 年 4 月 7 日
Hi Everyone,
My Situation:
I am trying to use a MATLAB plot to generate a representation of a geometry I have. The Geometry consists of line segments that branch off of each other. To keep my indexing simplistic I use a single for loop to loop through the two arrays containing my segments. Each plot visualizes a different quantity on the same geometry.
Here is my code outline below:
function VesselPlot(Array1,Array2)
set(0,'DefaultFigureVisible','off')
fig1=figure('visible','off');
fig2=figure('visible','off');
for i = 1:length(Array1)
%Array 1
% create line coordinates for plot
startPoint=Array1(i).startpoint;
endPoint=Array1(i).endpoint;
x1 = [startPoint.x;endPoint.x];
y1 = [startPoint.y;endPoint.y];
z1 = [startPoint.z;endPoint.z];
%quantity 1
figure(fig1);
hold on
plot(x1,y1);
hold off
% quantitiy 2
figure(fig2);
hold on
plot(x1,y1);
hold off
% Array 2
% create line coordinates for plot
startPoint=Array2(i).startpoint;
endPoint=Array2(i).endpoint;
x1 = [startPoint.x;endPoint.x];
y1 = [startPoint.y;endPoint.y];
z1 = [startPoint.z;endPoint.z];
%quantity 1
figure(fig1);
hold on
plot(x1,y1);
hold off
% quantitiy 2
figure(fig2);
hold on
plot(x1,y1);
hold off
end
set(0,'DefaultFigureVisible','on')
figure(fig1)
figure(fig2)
end
My problem is that every time I call figure(*) the current figure becomes visible. each matrix can contain up to 300 line segments so this changing gets quite annoying.
I was hoping for a way to avoid making the plots in two different passes. I have attached the final results of one of two plots below. This plot is based on the full code and not the outline provided. My goal is to prevent the figures from flashing on screen
%

採用された回答

Geoff Hayes
Geoff Hayes 2015 年 4 月 7 日
Will - rather than calling figure to set "focus" to the figure that you wish to update with the new call to plot, just tell plot which axes to draw the updated graphics on. For example,
% get the handles to the figures and their axes
hFig1 = figure('visible','off');
hAxes1 = gca;
hFig2 = figure('visible','off');
hAxes2 = gca;
Then when you call plot just do instead
plot(hAxes1, x1, x2);
or whichever axes you wish to draw to.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by