Raw File
plot_contour.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file is part of NS2DDV.                                                      %
%                                                                                   %
% Copyright(C) 2011-2018    C. Calgaro  (caterina.calgaro@math.univ-lille1.fr)      %
%                           E. Creusé   (emmanuel.creuse@math.univ-lille1.fr)       %
%                           T. Goudon   (thierry.goudon@inria.fr)                   %
%                           A. Mouton   (alexandre.mouton@math.univ-lille1.fr)      %
%                                                                                   %
% NS2DDV is free software: you can redistribute it and/or modify it under the terms %
% of the GNU General Public License as published by the Free Software Foundation,   %
% either version 3 of the License, or (at your option) any later version.           %
%                                                                                   %
% NS2DDV is distributed in the hope that it will be useful, but WITHOUT ANY         %
% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A   %
% PARTICULAR PURPOSE. See the GNU General Public License for more details.          %
%                                                                                   %
% You should have received a copy of the GNU General Public License along with      %
% NS2DDV. If not, see <http://www.gnu.org/licenses/>.                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function[] = plot_contour(data, p, t, levels, titleplot, handle)

	% INPUT
	% data			The data to be plotted
	% p				Nodes
	% t				Triangles
	% levels		Isovalues associated to the plotted data
	% titleplot		Title of the graph
	% handle		Matlab graph handle

	cla;

	if (numel(levels) > 0)
		[cs,h] = tricont(p(1,:)', p(2,:)', t', data, levels);
	else
		[cs,h] = tricont(p(1,:)', p(2,:)', t', data);
	end
	title(titleplot);

	hc = get(h,'children');
	newlevels = zeros(length(h),1);
	for n=1:length(h)
		newlevels(n) = get(h(n),'UserData');
	end
	% remove duplicates
	[newlevels,I] = unique(newlevels);
	h = h(I);
	% sort (here in descending order)
	[newlevels,I] = sort(newlevels,'descend');
	h = h(I);
	% remove NaN values that are assigned if limits are used in the plot
	h = h(isfinite(newlevels));
	newlevels = newlevels(isfinite(newlevels));

	xmin = min(p(1,:));
	xmax = max(p(1,:));
	ymin = min(p(2,:));
	ymax = max(p(2,:));
	axis equal tight;
	axis([xmin xmax ymin ymax]);
	colormap(jet)
	lgd = colorbar;

	drawnow;

end
back to top