Skip to content
Snippets Groups Projects
plot_Tsg.m 3.5 KiB
Newer Older
jacques.grelet_ird.fr's avatar
jacques.grelet_ird.fr committed
function plot_Tsg( hTsgGUI, hAxes, PlotNum, X, Y, QC, para, colVal, ...
%
% Function to plot TSG parameters
% The program can plot parameter of style SSPS or SSPS_ADJUSTED
% in that last case we need to extract the name of the parameter
%
% Input
% -----
% hTsgGUI ........ Handle to the user interface
% hAxes   ........ Handle to the graphic axes
% PlotNum ........ Plot Number (used for the TAG)
% X
% Y
% QC ............. QC array - If empty plot using  Color specification
% para
% colVal ..........[]       - Draw Para taking into account color QC code
%                  'k''b'... - Draw Para using Color code
% lineType ....... Matlab type : 'none', '-', '--', ':', '-.'
% markType ....... Matlab type
% markSize ....... Integer
% Para ........... Parametre whose difference with TSG data is plot
% Get the data from the application GUI
% -------------------------------------
tsg = getappdata( hTsgGUI, 'tsg_data');

% test if there is data to plot
% -----------------------------
if ~isempty( X ) && ~isempty( Y )
  % get current axes
  if verLessThan('matlab', '9.1.0')  % R2016b
    axes( hAxes(PlotNum) );
  end
  
  % plot data with QC
  % -----------------
  if ~isempty(QC)
    % get list of keys from hashtable tsg.qc.hash, defined inside
    % tsg_initialisation.m
    % -----------------------------------------------------------
    % plot Sample/TSG differences on axe 2
    % iterate (loop) on each key store inside hastable
    % ------------------------------------------------
      % get key and some values in hashtable
      % old way: qcCode  = get(tsg.qc.hash, key, 'code')
      % --------------------------------------------------
      % qcState = tsg.qc.hash.(key).state;
      qcCode = tsg.qc.hash.(key).code;
      qcColor = tsg.qc.hash.(key).color;
      
Yves Gouriou's avatar
Yves Gouriou committed
      % plot tsg salinity sample with right code/color
      % ----------------------------------------------
Yves Gouriou's avatar
Yves Gouriou committed
      ind = find( QC == qcCode );
      if ~isempty( ind )
        if verLessThan('matlab', '9.1.0')  % R2016b
          line(X(ind), Y(ind), ...
            'Tag', ['TAG_PLOT' num2str(PlotNum) '_LINE_' para '_' char(key)],...
            'LineStyle', lineType, ...
            'Marker', markType, 'MarkerSize', markSize, 'Color', qcColor);
        else
          line(hAxes(PlotNum), X(ind), Y(ind), ...
            'Tag', ['TAG_PLOT' num2str(PlotNum) '_LINE_' para '_' char(key)],...
            'LineStyle', lineType, ...
            'Marker', markType, 'MarkerSize', markSize, 'Color', qcColor);
        end
Yves Gouriou's avatar
Yves Gouriou committed
      end
    if isempty(colVal)
      colVal = 'k';
    end
    if verLessThan('matlab', '9.1.0')  % R2016b
      line(X, Y, 'Tag', ['TAG_PLOT' num2str(PlotNum) '_LINE_' para], ...
        'LineStyle', lineType, ...
        'Marker', markType, 'MarkerSize', markSize, 'Color', colVal);
    else
      line(hAxes(PlotNum), X, Y, 'Tag', ['TAG_PLOT' num2str(PlotNum) '_LINE_' para], ...
        'LineStyle', lineType, ...
        'Marker', markType, 'MarkerSize', markSize, 'Color', colVal);
    end
% ------------------
set(get(hAxes(PlotNum), 'Ylabel'), 'Interpreter', 'none', 'String', para);
% update axes YLim property after zoom and with a new parameter
% -------------------------------------------------------------
% set(hAxes(PlotNum), 'YLimMode', 'auto');