Home > data-utility > granger_causality > gcause_libs > visualize_gcause_matrix_all_kids.m

visualize_gcause_matrix_all_kids

PURPOSE ^

SYNOPSIS ^

function visualize_gcause_matrix_all_kids(gcause_mat, var_module_list, save_name)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function visualize_gcause_matrix_all_kids(gcause_mat, var_module_list, save_name)
0002 
0003 color_max = 40;
0004 color_pos = get_colormap('red', color_max);
0005 color_neg = get_colormap('blue', color_max);
0006 num_vars = length(var_module_list);
0007 
0008 plot_xlim = [0 num_vars];
0009 plot_ylim = [0 num_vars];
0010 h = figure();
0011 hold on;
0012 % plot row by row
0013 for rowidx = 1:num_vars
0014     plot_y_one = num_vars - rowidx;
0015     block_y = [plot_y_one plot_y_one+1 plot_y_one+1 plot_y_one];
0016     text_y = mean(block_y);
0017     % row var text
0018     text(-0.05, text_y, ['\rightarrow' var_module_list{rowidx}], 'HorizontalAlignment', 'right');
0019     
0020     for colidx = 1:num_vars
0021         block_x = [colidx-1 colidx-1 colidx colidx];
0022 
0023         gcause_one = gcause_mat(rowidx, colidx);
0024         color_index = min(round(abs(gcause_one))+1, color_max);
0025         if gcause_one > 0
0026             block_color = color_pos(color_index, :);
0027         else
0028             block_color = color_neg(color_index, :);
0029         end
0030         fill(block_x, block_y, block_color, 'EdgeColor', 'k');
0031         text_x = mean(block_x);
0032         text(text_x, text_y, sprintf('%.2f', gcause_one), 'HorizontalAlignment', 'center');
0033         
0034         if rowidx < 2
0035             % column var text
0036             text(text_x, (num_vars+0.1), ['\leftarrow' var_module_list{colidx}], 'HorizontalAlignment', 'center');
0037         end
0038     end
0039 end
0040 hold off;
0041 xlim(plot_xlim);
0042 ylim(plot_ylim);
0043 set(gca,'xticklabel',{[]});
0044 set(gca,'yticklabel',{[]});
0045 
0046 if nargin > 2
0047     saveas(h, save_name);
0048     close(h);
0049 end

Generated on Wed 24-May-2017 00:00:56 by m2html © 2005