Suppress contourm figure window
Show older comments
I am trying to selectively generate contour lines from a geographic data set. I am using contourm which is returning the correct contour values; however, the function call always returns a figure. See example, fake data, but real code.
% max lat/lon
limLat = [37.76 41.78];
limLon = [-88.13 -84.69];
% create a new grid
n = 20;
gridSize = [n n];
latvec = linspace(limLat(1), limLat(2), gridSize(1));
lonvec = linspace(limLon(1), limLon(2), gridSize(2));
[LatQ LonQ] = ndgrid(latvec, lonvec);
z = peaks(n);
% this line of code calculates the contour BUT correctly returns a figure
% plot
[c1] = contourm(LatQ, LonQ, z, [0,0]);
I tried changing the code to:
[c1] = contourm(LatQ, LonQ, z, [0,0], 'Visible', 'off');
This returns c1 and blank figure. So I tried adding 'HandleVisibility'. Same result.
How do I suppress the figure generation? I would prefer not to create an invisible figure as I need to run this in a parallelized loop.
Answers (1)
Jan
on 22 Apr 2021
The HandleVisibility manages the visibility of the handle for searching with e.g. findall. This does not mean the optical visibility, but only if the object can be selected automatically.
Open the source of contourm to find out, how it works:
edit contourm
I do not have the mapping toolbox, so I cannot try this. But it looks like you can provide an axes as input, such that contourm does not creazte a new one. I do not understand, why you do not want to provide such a figure, e.g. an invisible one, because of a parfor loop. This is no contradiction, if each loop get its own figure.
As far as I understand from the code of contourm, a graphic tools is used to determine the contour. Then there is no way to "cheat" without opening a figure. Maybe you can use another tool to determine the contour?
2 Comments
Douglas Mitchell
on 22 Apr 2021
Edited: Douglas Mitchell
on 22 Apr 2021
Jan
on 22 Apr 2021
This means, that contourm is not a matching tool to solve your problem.
Categories
Find more on Geographic Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!