Skip to content

Commit

Permalink
iss #7 Updated xp_matrix_imagesc
Browse files Browse the repository at this point in the history
  • Loading branch information
davestanley committed Apr 1, 2017
1 parent 2f0900a commit d60c716
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
17 changes: 9 additions & 8 deletions library_plots/xp_matrix_imagesc.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function xp_matrix_imagesc (xp,options)
if ~isfield(options,'ylims'); options.ylims = []; end
if ~isfield(options,'xdat'); options.xdat= []; end
if ~isfield(options,'ydat'); options.ydat = []; end
if ~isfield(options,'clims'); options.clims = []; end
if ~isfield(options,'show_colorbar'); options.show_colorbar = 0; end
if ~isfield(options,'zlims'); options.zlims = []; end
if ~isfield(options,'do_colorbar'); options.do_colorbar = false; end
% Display_mode: 0-Just plot directly
% 1-Plot as an image (cdata)
% 2-Save to a figure file
Expand All @@ -26,26 +26,27 @@ function xp_matrix_imagesc (xp,options)
ylims = options.ylims;
xdat = options.xdat;
ydat = options.ydat;
clims = options.clims;
show_colorbar = options.show_colorbar;
zlims = options.zlims;
do_colorbar = options.do_colorbar;


if transpose_on;
if transpose_on
d = xp.data{1}';
else
d = xp.data{1}';
end

if ~isempty(clims)
imagesc(xdat,ydat,d,clims);
if ~isempty(zlims)
imagesc(xdat,ydat,d,zlims);
else
imagesc(xdat,ydat,d);
end
set(gca,'YDir','normal');

if ~isempty(xlims); xlim(xlims); end
if ~isempty(ylims); ylim(ylims); end

if show_colorbar
if do_colorbar
colorbar;
end

Expand Down
9 changes: 9 additions & 0 deletions library_plots/xp_subplot_grid.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
op = struct_addDef(op,'display_mode',0);
op = struct_addDef(op,'subplotzoom_enabled',1);
op = struct_addDef(op,'legend1',[]);
op = struct_addDef(op,'do_colorbar',false);
op = struct_addDef(op,'max_legend',20);
op = struct_addDef(op,'force_rowvect',false);
op = struct_addDef(op,'zlims',[]);
% Display_mode: 0-Just plot directly
% 1-Plot as an image (cdata)
% 2-Save to a figure file
Expand All @@ -23,6 +25,8 @@
display_mode = op.display_mode;
subplotzoom_enabled = op.subplotzoom_enabled;
legend1 = op.legend1;
do_colorbar = op.do_colorbar;
zlims = op.zlims; % This might be used for setting the colorbar limits (clims), but cannot get it working with subplot_grid

if verLessThan('matlab','8.4') && display_mode == 1; warning('Display_mode==1 might not work with earlier versions of MATLAB.'); end
if transpose_on && ismatrix(xp)
Expand Down Expand Up @@ -68,6 +72,11 @@
% Place a legend in the 1st subplot
legend(legend1{1:min(end,op.max_legend)});
end
if i == 1 && j == 1 && do_colorbar
colorbar;
%hsg.colorbar;
%hsg.colorbar([],zlims);
end
end
end

Expand Down

0 comments on commit d60c716

Please sign in to comment.