plot_color.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_color(data, p, t, titleplot, handle)
% INPUT
% data The data to be plotted
% p Nodes
% t Triangles
% titleplot Title of the graph
% handle Matlab graph handle
cla;
xmin = min(p(1,:));
xmax = max(p(1,:));
ymin = min(p(2,:));
ymax = max(p(2,:));
axis equal tight;
axis([xmin xmax ymin ymax]);
title(titleplot);
lgd = colorbar;
if (numel(data) == size(p,2))
% Data is node centered
if (size(data,1) == 1)
twod_plotc(handle, p', t', data');
else
twod_plotc(handle, p', t', data);
end
else if (numel(data) == size(t,2))
% Data is cell centered
x = zeros(size(t));
y = zeros(size(t));
for ke=1:size(t,2)
for i=1:3
x(i,ke) = p(1,t(i,ke));
y(i,ke) = p(2,t(i,ke));
end
end
patch(x, y, data, 'linestyle', 'none');
else
error('Cannot determine whether the data is node centered or cell centered');
end
drawnow;
end