Skip to content

Commit

Permalink
In the main window, any 1D parameter of the selected instrument is no…
Browse files Browse the repository at this point in the history
…w always plotted with a blue coloured line. Alternating random colours for different parameters of the same instrument was not justified.
  • Loading branch information
ggalibert committed Jul 19, 2017
1 parent 16fdf84 commit 4fdeed8
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 43 deletions.
13 changes: 7 additions & 6 deletions Graph/DepthProfile/graphDepthProfileGeneric.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
function [h, labels] = graphDepthProfileGeneric( ax, sample_data, var )
function [h, labels] = graphDepthProfileGeneric( ax, sample_data, var, color )
%GRAPHDEPTHPROFILEGENERIC Plots the given variable (x axis) against depth
% (y axis).
%
% Inputs:
% ax - Parent axis.
% sample_data - The data set.
% var - The variable to plot.
% color - The color to be used to plot the variable.
%
% Outputs:
% h - Handle(s) to the line(s) which was/were plotted.
Expand Down Expand Up @@ -44,7 +45,7 @@
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.
%
narginchk(3,3);
narginchk(4,4);

if ~ishandle(ax), error('ax must be a graphics handle'); end
if ~isstruct(sample_data), error('sample_data must be a struct'); end
Expand All @@ -71,20 +72,20 @@

switch mode
case 'profile'
h = line(var.data(:, 1), depth.data(:, 1), 'Parent', ax, 'LineStyle', '-'); % downcast
h = line(var.data(:, 1), depth.data(:, 1), 'Parent', ax, 'LineStyle', '-', 'Color', color); % downcast
if size(var.data, 2) > 1
h(end+1) = line(var.data(:, 2), depth.data(:, 2), 'Parent', ax, 'LineStyle', '--'); % upcast
h(end+1) = line(var.data(:, 2), depth.data(:, 2), 'Parent', ax, 'LineStyle', '--', 'Color', color); % upcast
end

case 'timeSeries'
if size(var.data, 2) > 1
% ADCP data, we look for vertical dimension
iVertDim = var.dimensions(2);
for i=1:size(var.data, 2)
h(i) = line(var.data(:, i), depth.data - sample_data.dimensions{iVertDim}.data(i), 'Parent', ax, 'LineStyle', '-');
h(i) = line(var.data(:, i), depth.data - sample_data.dimensions{iVertDim}.data(i), 'Parent', ax, 'LineStyle', '-', 'Color', color);
end
else
h = line(var.data, depth.data, 'Parent', ax, 'LineStyle', '-');
h = line(var.data, depth.data, 'Parent', ax, 'LineStyle', '-', 'Color', color);
end

end
Expand Down
2 changes: 1 addition & 1 deletion Graph/Transect/graphTransectGeneric.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [h labels] = graphTransectGeneric( ax, sample_data, var )
function [h, labels] = graphTransectGeneric( ax, sample_data, var )
%GRAPHTRANSECTGENERIC Plots the given variable as 2d transect data. Assumes
% that the sample data struct contains latitude and longitude variable data.
%
Expand Down
7 changes: 4 additions & 3 deletions Graph/XvY/graphXvYGeneric.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
function [h, labels] = graphXvYGeneric( ax, sample_data, vars )
function [h, labels] = graphXvYGeneric( ax, sample_data, vars, color )
%GRAPHXVYGENERIC Plots the given variable (x axis) against another
% (y axis).
%
% Inputs:
% ax - Parent axis.
% sample_data - The data set.
% vars - The variables to plot.
% color - The color to be used to plot the variable.
%
% Outputs:
% h - Handle(s) to the line(s) which was/were plotted.
Expand Down Expand Up @@ -44,7 +45,7 @@
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.
%
narginchk(3,3);
narginchk(4,4);

if ~ishandle(ax), error('ax must be a graphics handle'); end
if ~isstruct(sample_data), error('sample_data must be a struct'); end
Expand All @@ -53,7 +54,7 @@
xdata = sample_data.variables{vars(1)}.data;
ydata = sample_data.variables{vars(2)}.data;

h = line(xdata, ydata);
h = line(xdata, ydata, 'Color', color);
set(ax, 'Tag', 'axis1D');

% for global/regional range display
Expand Down
13 changes: 1 addition & 12 deletions Graph/graphDepthProfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,9 @@
'Color', 'none',...
'YGrid', 'on');

% make sure line colour alternate; because we are creating
% multiple axes, this is not done automatically for us
col = get(graphs(k), 'ColorOrder');
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));

% set the line colour - wrap in a try block,
% as surface plot colour cannot be set
try set(lines(k,:), 'Color', col);
catch e
end
[lines(k,:), labels] = plotFunc(graphs(k), sample_data, vars(k), 'b'); % current variable is always plotted in blue

% set x label
uom = '';
Expand Down
15 changes: 1 addition & 14 deletions Graph/graphTimeSeries.m
Original file line number Diff line number Diff line change
Expand Up @@ -181,22 +181,9 @@
'XTickLabel', xTickLabels, ...
'YLim', yLimits, ...
'YTick', yTicks);

% make sure line colour alternate; because we are creating
% multiple axes, this is not done automatically for us
col = get(graphs(k), 'ColorOrder');

% we get rid of the red color which is used for global range boundaries
% and in/out water boundaries
iRed = (col == repmat([1 0 0], [size(col, 1), 1]));
iRed = sum(iRed, 2);
iRed = iRed == 3;
col(iRed, :) = [];

col = col(mod(vars(k),length(col))+1,:);

% plot the variable
[lines(k,:), labels] = plotFunc(graphs(k), sample_data, k, col, xTickProp);
[lines(k,:), labels] = plotFunc(graphs(k), sample_data, k, 'b', xTickProp); % current variable is always plotted in blue

if ~isempty(labels)
% set x labels and ticks
Expand Down
8 changes: 4 additions & 4 deletions Graph/graphTransect.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [graphs lines vars] = graphTransect( parent, sample_data, vars )
function [graphs, lines, vars] = graphTransect( parent, sample_data, vars )
%GRAPHTRANSECT Graphs the given data in a 2D transect manner, using subplot.
%
% Inputs:
Expand Down Expand Up @@ -89,13 +89,13 @@

set(graphs(k), 'Parent', parent,...
'XGrid', 'on',...
'Color', 'none',...
'Color', 'none',...
'YGrid', 'on', ...
'ZGrid', 'on');

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

% set labels
set(get(graphs(k), 'XLabel'), 'String', labels{1}, 'Interpreter', 'none');
Expand Down
4 changes: 1 addition & 3 deletions Graph/graphXvY.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@

% plot the variable
plotFunc = getGraphFunc('XvY', 'graph', xname);
[lines, labels] = plotFunc(graphs, sample_data, vars);

set(lines, 'Color', 'blue');
[lines, labels] = plotFunc(graphs, sample_data, vars, 'b'); % current variable is always plotted in blue

% set x label
uom = '';
Expand Down

0 comments on commit 4fdeed8

Please sign in to comment.