Skip to content

Commit

Permalink
Improved alignment of 1D and 2D plots on the X axis for better compat…
Browse files Browse the repository at this point in the history
…ibility across Matlab versions.
  • Loading branch information
sspagnol authored and ggalibert committed Dec 15, 2016
1 parent 6f1237e commit 7acd22a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 29 deletions.
26 changes: 0 additions & 26 deletions Graph/TimeSeries/graphTimeSeriesGeneric.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,32 +89,6 @@
end
end

% Set axis position so that 1D data and 2D data vertically matches on X axis
mainPanel = findobj('Tag', 'mainPanel');
last_pos_with_colorbar = get(mainPanel, 'UserData');
if isempty(last_pos_with_colorbar) % this is to avoid too many calls to colorbar()
cb = colorbar();
set(get(cb, 'YLabel'), 'String', 'TEST');
pos_with_colorbar = get(ax, 'Position');
last_pos_with_colorbar = pos_with_colorbar;
colorbar(cb, 'off');
set(mainPanel, 'UserData', last_pos_with_colorbar);
else
pos_with_colorbar = get(ax, 'Position');

if pos_with_colorbar(1) == last_pos_with_colorbar(1)
pos_with_colorbar(3) = last_pos_with_colorbar(3);
else
cb = colorbar();
set(get(cb, 'YLabel'), 'String', 'TEST');
pos_with_colorbar = get(ax, 'Position');
last_pos_with_colorbar = pos_with_colorbar;
colorbar(cb, 'off');
set(mainPanel, 'UserData', last_pos_with_colorbar);
end
end
set(ax, 'Position', pos_with_colorbar);

% set background to be grey
set(ax, 'Color', [0.75 0.75 0.75])

Expand Down
8 changes: 7 additions & 1 deletion Graph/TimeSeries/graphTimeSeriesTimeDepth.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,15 @@
% xPcolor = [time.data(1:end-1) - diff(time.data)/2; time.data(end) - (time.data(end)-time.data(end-1))/2];
% yPcolor = [depth.data(1:end-1) - diff(depth.data)/2; depth.data(end) - (depth.data(end)-depth.data(end-1))/2];

posWithoutCb = get(ax, 'Position');

h = pcolor(ax, double(xPcolor), double(yPcolor), double(var.data'));
set(h, 'FaceColor', 'flat', 'EdgeColor', 'none');
cb = colorbar();
cb = colorbar('peer', ax);

% reset position to what it was without the colorbar so that it aligns with
% 1D datasets
set(ax, 'Position', posWithoutCb);

% Attach the context menu to colorbar
hMenu = setTimeSerieColorbarContextMenu(var);
Expand Down
2 changes: 1 addition & 1 deletion Graph/TimeSeries/graphTimeSeriesTimeFrequency.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

h = pcolor(ax, double(xPcolor), double(yPcolor), double(var.data'));
set(h, 'FaceColor', 'flat', 'EdgeColor', 'none');
cb = colorbar();
cb = colorbar('peer',ax);

% Attach the context menu to colorbar
hMenu = setTimeSerieColorbarContextMenu(var);
Expand Down
2 changes: 1 addition & 1 deletion Graph/TimeSeries/graphTimeSeriesTimeFrequencyDirection.m
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
'Position' , posUi2(mainPanel, 50, 1, 50, 1, 0), ...
'String' ,'Time cursor');

cb = colorbar();
cb = colorbar('peer',ax);

% Attach the context menu to colorbar
hMenu = setTimeSerieColorbarContextMenu(myVar);
Expand Down

0 comments on commit 7acd22a

Please sign in to comment.