function plot_Sample( hTsgGUI, hPlotAxes )
%
% Function to plot :
% 1 - SAMPLE/TSG differences on axes 2
% 2 - Raw tsg and tsg -adjusted on axe 3
% 3 - do not draw anything on axes 1
%
% Input
% -----
% hTsgGUI ........ Handel to the user interface
% hPlotAxes ...... Handels to the graphic axes
%

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

% 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
% ------------------------------------
axes(hPlotAxes(2));
hold off;

% 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.SSPS_QC == code );
    plot(hPlotAxes(2), sample.DAYD(ind), sample.SSPS_DIF(ind), strcat('.', color));
  end
end

hold off;      

% Plot tsg.SSPS and tsg.SSPS_ADJUSTED on axes 3
% ---------------------------------------------
plot_TsgAdjusted( hTsgGUI, hPlotAxes );

% Formatted x-TIME axes
% ---------------------
set(hPlotAxes(2), 'Xlim', [tsg.DAYD(1)-1 tsg.DAYD(end)+1]);

datetick(hPlotAxes(1), 'x', 'keeplimits');
datetick(hPlotAxes(2), 'x', 'keeplimits');
datetick(hPlotAxes(3), 'x', 'keeplimits');

% Write some 'Y' label
% ------------------
set(get(hPlotAxes(2), 'Ylabel'), 'String', 'Salinity Difference');

% Make the axes visible
% ---------------------
set(hPlotAxes(1), 'Visible', 'on' );
set(hPlotAxes(2), 'Visible', 'on' );
set(hPlotAxes(3), 'Visible', 'on' );

% The 3 axes will behave identically when zoomed and panned
% ---------------------------------------------------------
linkaxes([hPlotAxes(1),hPlotAxes(2),hPlotAxes(3)], 'x');

end
