Skip to content

Commit

Permalink
better colormap positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Julie-Fabre committed Nov 5, 2023
1 parent a511af1 commit b1db422
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/uglyPlot.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
c2 = colorbar;
c2.Title.String = 'Zscore';

%prettify_plot;
prettify_plot;
5 changes: 3 additions & 2 deletions prettify_plot/prettify_colorbar.asv
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ for iColorBar = 1:length(colorbars)
currColorbar.Title.String = '';
elseif ~isempty(currColorbar.XLabel.String) %x label string
label = currColorbar.Xlabel.String;
currColorbar.Label.String = '';
currColorbar.Xlabel.String = '';
else
label = '';
end
Expand All @@ -40,7 +40,8 @@ for iColorBar = 1:length(colorbars)

currColorbar.Parent = colorbarProperties(iColorBar).Parent;
currColorbar.Units = 'Points';
currColorbar.Position = [400, colorbarProperties(iColorBar).Position_ori(2:4)]; % QQ hardcoded
colorbarProperties(iColorBar).Parent.Position
currColorbar.Position = [colorbarProperties(iColorBar).Position_ori(1)+35, colorbarProperties(iColorBar).Position_ori(2:4)]; % QQ hardcoded
currColorbar.Label.String = colorbarProperties(iColorBar).Label;%QQ error - this doesn't work with XLabel.
currColorbar.Label.Rotation = 270; % Rotate the label to be horizontal
currColorbar.Label.Position = [3, 0.5, 0]; % You might need to adjust these values
Expand Down
7 changes: 4 additions & 3 deletions prettify_plot/prettify_colorbar.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ function prettify_colorbar(colorbars, ChangeColormaps, DivergingColormap,...
colorbarProperties(iColorBar).Position_ori = currColorbar.Position;

currColorbar.Parent = colorbarProperties(iColorBar).Parent;
currColorbar.Units = 'Points';
currColorbar.Position = [colorbarProperties(iColorBar).Position_ori(1)+35, colorbarProperties(iColorBar).Position_ori(2:4)]; % QQ hardcoded
%currColorbar.Units = 'Points';
%colorbarProperties(iColorBar).Parent.Position
%currColorbar.Position = [colorbarProperties(iColorBar).Position_ori(1)+35, colorbarProperties(iColorBar).Position_ori(2:4)]; % QQ hardcoded
currColorbar.Label.String = colorbarProperties(iColorBar).Label;%QQ error - this doesn't work with XLabel.
currColorbar.Label.Rotation = 270; % Rotate the label to be horizontal
currColorbar.Label.Position = [3, 0.5, 0]; % You might need to adjust these values

currColorbar.Limits = colorbarProperties(iColorBar).Limits;
currColorbar.Units = 'Normalized'; % set back to normalized so it scales with figure
%currColorbar.Units = 'Normalized'; % set back to normalized so it scales with figure

% add colorbar limits above and below
% currColorbar.Title.String = num2str(colorbarProperties(iColorBar).Limits(2));
Expand Down

0 comments on commit b1db422

Please sign in to comment.