Skip to content

Commit

Permalink
Fix graphing in DepthProfile mode to initially zoom on good/probably …
Browse files Browse the repository at this point in the history
…good/raw data only.
  • Loading branch information
ggalibert committed Apr 5, 2017
1 parent 14ba0e1 commit 2f84921
Showing 1 changed file with 18 additions and 45 deletions.
63 changes: 18 additions & 45 deletions Graph/graphDepthProfile.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [graphs lines vars] = graphDepthProfile( parent, sample_data, vars )
function [graphs, lines, vars] = graphDepthProfile( parent, sample_data, vars )
%GRAPHDEPTHPROFILE Graphs the given data in a depth profile style using
% subplots.
%
Expand All @@ -9,7 +9,7 @@
% Inputs:
% parent - handle to the parent container.
% sample_data - struct containing sample data.
% vars - Indices of variables that should be graphed..
% vars - Indices of variables that should be graphed.
%
% Outputs:
% graphs - A vector of handles to axes on which the data has
Expand Down Expand Up @@ -143,8 +143,8 @@
col = col(mod(k, length(col))+1, :);

% plot the variable
plotFunc = getGraphFunc('DepthProfile', 'graph', name);
[lines(k,:) labels] = plotFunc( graphs(k), sample_data, vars(k));
plotFunc = getGraphFunc('DepthProfile', 'graph', name);
[lines(k,:), labels] = plotFunc(graphs(k), sample_data, vars(k));

% set the line colour - wrap in a try block,
% as surface plot colour cannot be set
Expand Down Expand Up @@ -172,28 +172,31 @@

if sample_data.meta.level == 1 && strcmp(func2str(plotFunc), 'graphDepthProfileGeneric')
qcSet = str2double(readProperty('toolbox.qc_set'));

% set x and y limits so that axis are optimised for data below surface only
goodFlag = imosQCFlag('good', qcSet, 'flag');
pGoodFlag = imosQCFlag('probablyGood', qcSet, 'flag');
rawFlag = imosQCFlag('raw', qcSet, 'flag');

% set x and y limits so that axis are optimised for good/probably good/raw data only
curData = sample_data.variables{vars(k)}.data;
curDepth = depth.data;
curFlag = sample_data.variables{vars(k)}.flags;
iGood = curDepth>=0;

yLimits = [floor(min(curDepth(iGood))), ceil(max(curDepth(iGood)))];
xLimits = [floor(min(curData(iGood))), ceil(max(curData(iGood)))];
iGood = (curFlag == goodFlag) | (curFlag == pGoodFlag) | (curFlag == rawFlag);
yLimits = [floor(min(curDepth(iGood))*10)/10, ceil(max(curDepth(iGood))*10)/10];
xLimits = [floor(min(curData(iGood))*10)/10, ceil(max(curData(iGood))*10)/10];

%check for my surface soak flags - and set xLimits to flag range
if ismember(name,{'tempSoakStatus','cndSoakStatus','oxSoakStatus'})
xLimits=[min(imosQCFlag('flag',qcSet,'values')) max(imosQCFlag('flag',qcSet,'values'))];
if ismember(name, {'tempSoakStatus', 'cndSoakStatus', 'oxSoakStatus'})
xLimits = [min(imosQCFlag('flag', qcSet, 'values')) max(imosQCFlag('flag', qcSet, 'values'))];
end

%check for xLimits max=min
if diff(xLimits)==0;
if diff(xLimits) == 0;
if xLimits(1) == 0
xLimits = [-1, 1];
else
eps=0.01*xLimits(1);
xLimits=[xLimits(1)-eps, xLimits(1)+eps];
eps = 0.01 * xLimits(1);
xLimits = [xLimits(1) - eps, xLimits(1) + eps];
end
end

Expand All @@ -209,34 +212,4 @@
set(graphs(k), 'YTick', yTicks);

end

% GLT : Eventually I prefered not displaying the QC legend as it
% influences too badly the quality of the plots. I didn't manage to have
% a satisfying result with a ghost axis hosting the legend... So for now
% I added the possiblity to the user to right-click on a QC'd data point
% and it displays the description of the color flag.
% compile variable names for the legend
% names = {};
% for k = 1:length(vars)
%
% names{k} = sample_data.variables{vars(k)}.name;
% end
%
% % link axes for panning/zooming, and add a legend - matlab has a habit of
% % throwing 'Invalid handle object' errors for no apparent reason (i think
% % when the user changes selections too quickly, matlab is too slow, and
% % ends up confusing itself), so absorb any errors which are thrown
% try
% linkaxes(graphs, 'y');
%
% % When adding a single legend for multiple subplots, by default the legend
% % is added to the axis which corresponds to the first handle in the vector
% % that is passed in ('lines' in this case). This is a problem in our case,
% % because it means that the legend will be added to the left most axis,
% % whereas we want it to be added to the right-most axis. To get around
% % this, I'm reversing the order of the line handles (and names) before
% % passing them to the legend function.
% legend(flipud(lines(:,1)), fliplr(names));
% catch e
% end
end

0 comments on commit 2f84921

Please sign in to comment.