Home > utils > add_linestar.m

add_linestar

PURPOSE ^

SYNOPSIS ^

function add_linestar(cond_locs, cond_data, pval, params)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function add_linestar(cond_locs, cond_data, pval, params)
0002 
0003 if length(cond_locs) > 2
0004   fprintf('Cannot plot lines between more than 2 conditions\n')
0005   return
0006 end
0007 
0008 if nargin < 4
0009   params = struct();
0010 end
0011 
0012 % Check to see if format for string has been specified
0013 if ~isfield(params,'use_prob_text')
0014   params.use_prob_text = false;
0015 end
0016 
0017 if ~isfield(params, 'bottom_offset')
0018   params.bottom_offset = 1.1;
0019 end
0020 
0021 if ~isfield(params, 'top_offset')
0022   params.top_offset = 1.25;
0023 end
0024 
0025 % calculate where the lines will start at the bottom
0026 
0027 bottom_points = cond_data*params.bottom_offset;
0028 top_points = cond_data*params.top_offset;
0029 
0030 stop_y = max(top_points);
0031 
0032 % Plot vertical line segment above 1st condition
0033 for icond = 1:2
0034   curr_cond = cond_locs(icond);
0035   start_x = curr_cond;
0036   stop_x = start_x;
0037 
0038   start_y = bottom_points(icond);
0039 
0040   line([start_x stop_x], [start_y stop_y], 'color', [0 0 0])
0041 end
0042 
0043 % Add the top horizontal line
0044 line(cond_locs, [1 1]*stop_y, 'color',[0 0 0])
0045 
0046 if params.use_prob_text
0047   str = sprintf('pval: %1.4f', pval);
0048 else
0049   str = prob2str(pval,0.05,'*');
0050 end
0051 % Add significance as stars
0052 text(mean(cond_locs), stop_y*1.00, str,  ...
0053   'horizontalalign', 'center', ...
0054   'verticalalign', 'bottom', ...
0055   'fontsize', 14)
0056

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003