Skip to content
Snippets Groups Projects
plot_Sample.m 2.77 KiB
Newer Older
function plot_Sample( hTsgGUI, hAxes, PlotNum, Para, MyColor )
% Function to plot Para sample on axes hAxe
% The program can plot parameter of style SSPS or SSPS_DIF
% in that last case we need to extract the name of the parameter
%
% Input
% -----
% hTsgGUI ........ Handel to the user interface
% hPlotAxes ...... Handels to the graphic axes
% PlotNum ........ Plot Number (used for the TAG)
% Para ........... Parametre whose difference with TSG data is plot
% MyColor ........ []        - Draw Para taking into account color QC code
%                  'k''b'... - Draw Para using Color code 

% Retrieve named application data
% -------------------------------
sample    = getappdata( hTsgGUI, 'sample');
tsg       = getappdata( hTsgGUI, 'tsg_data');

axes( hAxes );
set( hAxes, 'Box', 'on' );
hold on
% Extract the name of the parameter
% ---------------------------------
pos = regexp( Para, '_', 'ONCE');
if isempty( pos )
  parameter = Para;
else
  parameter = Para(1:pos-1);
end

if isempty(MyColor)
  % get list of keys from hashtable tsg.qc.hash, defined inside
  % tsg_initialisation.m
  % -----------------------------------------------------------
  qc_list = get(tsg.qc.hash);

  % Plot Sample/TSG differences on axe 2
  % iterate (loop) on each key store inside hastable
  % ------------------------------------------------
  for i=1:numel(qc_list)

    % get key and some values in hashtable
    % ------------------------------------
    key   = qc_list{i};
    state = get(tsg.qc.hash, key, 'state');
    code  = get(tsg.qc.hash, key, 'code');
    color = get(tsg.qc.hash, key, 'color');

    % plot only for valid context menu (set to 'on')
    % ----------------------------------------------
    if strcmp( state, 'on')

      % plot tsg salinity sample with right code/color
      % ----------------------------------------------
      ind = find(sample.([parameter '_QC']) == code );
      if ~isempty( ind )

        line( sample.DAYD(ind), sample.(Para)(ind), ...
             'Tag', ['TAG_PLOT' num2str(PlotNum) '_LINE_' Para '_' key],...
             'LineStyle', 'none',...
             'Marker', 'square', 'MarkerSize', 3,...
             'MarkerEdgeColor', 'k', 'MarkerFaceColor', color);
        
      end
    end
  line( sample.DAYD, sample.(Para),...
        'Tag', ['TAG_PLOT' num2str(PlotNum) '_LINE_' Para],...
        'LineStyle', 'none',...
        'Marker', 'square', 'MarkerSize', 3,...
        'MarkerEdgeColor', MyColor, 'MarkerFaceColor', MyColor);

% Write some 'Y' label
% ------------------
set(get(hAxes, 'Ylabel'), 'Interpreter', 'none', 'String', Para);
% Formatted x-TIME axes
% ---------------------
set(hAxes, 'Xlim', [tsg.DAYD(1)-1 tsg.DAYD(end)+1]);