-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcallbackXRDPlot.m
59 lines (45 loc) · 1.79 KB
/
callbackXRDPlot.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function callbackXRDPlot(obj, evt, ternHandles, specHandles, ECHandles)
%CALLBACKXRDPLOT waits for the user to select a point on the ternary
%diagram and plots the XRD pattern at that point
set(ternHandles.buttonXRDPlot, 'Callback', []);
figTern = ternHandles.fTernDiagram;
ternInfo = figTern.UserData;
fSpecPlot = specHandles.fSpecPlot;
specInfo = fSpecPlot.UserData;
xTernPoints = ternInfo.xCoords;
yTernPoints = ternInfo.yCoords;
compA = ternInfo.valsCompA;
compB = ternInfo.valsCompB;
compC = ternInfo.valsCompC;
XRDData = specInfo.XRDData;
figure(ternHandles.fTernDiagram);
[xSelect, ySelect] = ginput(1);
indexPoint = findNearestPoint(xSelect, ySelect, ...
ternInfo.numPoints, xTernPoints, yTernPoints);
if ishandle(ternInfo.pointOutline) == 1
delete(ternInfo.pointOutline);
end
ternInfo.pointOutline = scatter(xTernPoints(indexPoint), ...
yTernPoints(indexPoint), 'k');
% plot XRD data for that point
if ishandle(ternInfo.fXRDPlot) == 1
figure(ternInfo.fXRDPlot);
clf;
else
ternInfo.fXRDPlot = figure;
set(gcf, 'color', 'w');
set(gcf, 'Name', 'XRD Plot for Selected Point');
end
axes('Units', 'Normalized', 'Position', [0.1 0.1 0.8 0.8]);
plot(XRDData(:, indexPoint * 2 - 1), XRDData(:, indexPoint * 2));
xlabel('Angle (2\theta)');
ylabel('Intensity');
displayString = sprintf('A: %f\nB: %f\nC: %f', ...
compA(indexPoint), compB(indexPoint), compC(indexPoint));
hold on;
legend(displayString, 'location', 'EastOutside');
figTern.UserData = ternInfo;
set(ternHandles.buttonXRDPlot, ...
'Callback', ...
{@callbackXRDPlot, ternHandles, specHandles, ECHandles});
end