forked from helgestein/htAx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotSpecData.m
99 lines (85 loc) · 3.1 KB
/
plotSpecData.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
function [] = plotSpecData(ternHandles, specHandles, ECHandles)
%PLOTSPECDATA plots the spec. data according to the user-selected region
figTern = ternHandles.fTernDiagram;
ternInfo = figTern.UserData;
fSpecPlot = specHandles.fSpecPlot;
specInfo = fSpecPlot.UserData;
XRDData = specInfo.XRDData;
constType = ternInfo.constType;
compA = ternInfo.valsCompA;
compB = ternInfo.valsCompB;
compC = ternInfo.valsCompC;
hEditConst = ternHandles.editConst;
hEditWidth = ternHandles.editWidth;
constPercent = hEditConst.UserData;
width = hEditWidth.UserData;
ternPlotType = ternInfo.ternPlotType;
numTernPoints = ternInfo.numPoints;
xTernCoord = ternInfo.xCoords;
yTernCoord = ternInfo.yCoords;
xPoly = ternInfo.xPoly;
yPoly = ternInfo.yPoly;
% highlight appropriate region on ternary diagram
if ternPlotType ~= 1
if ternPlotType ~= 3
if ishandle(ternInfo.highlight) == 1
delete(ternInfo.highlight);
end
ternInfo.highlight = plotTernHighlight(figTern, 1000, ...
constPercent, width, constType);
end
end
% get the correct set of composition data
if ternInfo.polySelected == 1
found = 0;
ids = 0;
for i = 1:numTernPoints
if inpolygon(xTernCoord(i), yTernCoord(i), xPoly, yPoly) == 1
found = found + 1;
ids(found) = i;
end
end
spreads(1) = range(compA(ids));
spreads(2) = range(compB(ids));
spreads(3) = range(compC(ids));
[~, indexMaxSpread] = max(spreads);
if indexMaxSpread == 1
specInfo.selectedComp = compA(ids);
specInfo.selectedCompPartner = compC(ids);
ternInfo.constType = 2;
elseif indexMaxSpread == 2
specInfo.selectedComp = compB(ids);
specInfo.selectedCompPartner = compA(ids);
ternInfo.constType = 0;
else
specInfo.selectedComp = compC(ids);
specInfo.selectedCompPartner = compB(ids);
ternInfo.constType = 1;
end
else
if constType == 0
ids = find(abs(compA - constPercent) < width);
specInfo.selectedComp = compB(ids);
specInfo.selectedCompPartner = compA(ids);
elseif constType == 1
ids = find(abs(compB - constPercent) < width);
specInfo.selectedComp = compC(ids);
specInfo.selectedCompPartner = compB(ids);
else
ids = find(abs(compC - constPercent) < width);
specInfo.selectedComp = compA(ids);
specInfo.selectedCompPartner = compC(ids);
end
end
fSpecPlot.UserData = specInfo;
figTern.UserData = ternInfo;
if isempty(ids) == 1
errordlg('No points selected');
else
ids = ids .* 2;
plotSpecSliders(specHandles.fSpecPlot, ...
XRDData(:, 1), XRDData(:, ids), ...
specInfo.selectedComp, specInfo.scaleType, ...
ternHandles, specHandles, ECHandles);
end
end