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

133 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by