Skip to content

Commit e2f803c

Browse files
authored
Fixes bug in contrast shift value and starts shift value at 0 (#435)
1 parent 115ce19 commit e2f803c

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

utilities/plotting/plotRefSLDHelper.m

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function plotRefSLDHelper(data, noDelay, linearX, q4, showErrorBar, showGrid, sh
4141
% showLegend : logical, default: true
4242
% Indicates if the legend should be shown.
4343
% shiftValue : float, default: 100
44-
% A value between 1 and 100 that controls the spacing between the reflectivity plots for each of the contrasts.
44+
% A value between 0 and 100 that controls the spacing between the reflectivity plots for each of the contrasts.
4545

4646
arguments
4747
data
@@ -51,8 +51,9 @@ function plotRefSLDHelper(data, noDelay, linearX, q4, showErrorBar, showGrid, sh
5151
showErrorBar {mustBeA(showErrorBar, 'logical')} = true
5252
showGrid {mustBeA(showGrid, 'logical')} = false
5353
showLegend {mustBeA(showLegend, 'logical')} = true
54-
shiftValue {mustBeGreaterThanOrEqual(shiftValue, 1), mustBeLessThanOrEqual(shiftValue, 100)} = 100
55-
end
54+
shiftValue {mustBeGreaterThanOrEqual(shiftValue, 0), mustBeLessThanOrEqual(shiftValue, 100)} = 100
55+
end
56+
5657
defaultState = 'on';
5758
s = warning();
5859
if any(strcmp({s.identifier}, 'MATLAB:Axes:NegativeDataInLogAxis'))
@@ -72,24 +73,24 @@ function plotRefSLDHelper(data, noDelay, linearX, q4, showErrorBar, showGrid, sh
7273

7374
if showGrid
7475
set(gca,'YGrid','on','XGrid','on');
75-
end
76+
end
77+
7678
hold on
7779
xlabel('$\textrm{Q}_{z} (\AA^{-1})$', 'Interpreter', 'Latex')
7880
ylabel('Reflectivity', 'Interpreter', 'Latex')
7981
lines = cell(numberOfContrasts, 1);
80-
mult = 1;
81-
q4Data = 1;
82+
q4Data = 1.0;
83+
8284
for i = 1:numberOfContrasts
8385
thisRef = data.reflectivity{i};
8486
thisData = data.shiftedData{i};
85-
if i > 1 || q4
86-
mult = 10.^((i/100)*shiftValue);
87-
end
88-
87+
8988
if q4 && data.dataPresent(i)
9089
q4Data = thisData(:,1).^4;
9190
end
92-
mult = q4Data/mult;
91+
92+
div = 10.0^(shiftValue*(i-1)/100.0);
93+
mult = q4Data/div;
9394
refY = thisRef(:,2) .* mult;
9495
% If there is data present
9596
% plot it - size of data.shiftedData
@@ -102,9 +103,9 @@ function plotRefSLDHelper(data, noDelay, linearX, q4, showErrorBar, showGrid, sh
102103
end
103104

104105
% Plot the fit
105-
lines{i} = plot(thisRef(:,1), refY, '-', 'LineWidth', 2);
106-
106+
lines{i} = plot(thisRef(:,1), refY, '-', 'LineWidth', 2);
107107
end
108+
108109
if showLegend
109110
legend([lines{:}], data.contrastNames{:});
110111
end

0 commit comments

Comments
 (0)