forked from helgestein/htAx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallbackECPlotTern.m
131 lines (113 loc) · 4.37 KB
/
callbackECPlotTern.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
function callbackECPlotTern(obj, evt, ternHandles, ECHandles)
%CALLBACKECPLOTTERN plots the calculated onset potentials and tafel slopes
%on a ternary diagram
figTern = ternHandles.fTernDiagram;
ternInfo = figTern.UserData;
fECPlot = ECHandles.fECPlot;
ECInfo = fECPlot.UserData;
ECPlotInfo = ECInfo.ECPlotInfo;
compA = ternInfo.valsCompA;
compB = ternInfo.valsCompB;
compC = ternInfo.valsCompC;
% get the points to plot (the ones with calculated tafel slope and
% onset potential)
pointsToPlot = zeros(1, 1);
binPoints = zeros(1, 1);
binPoints2 = zeros(1, 1);
numBinPoints = 0;
numBinPoints2 = 0;
numPointsToPlot = 0;
for i = 1:ternInfo.numPoints
if ECPlotInfo(i, 1) ~= 0
numPointsToPlot = numPointsToPlot + 1;
[pointsToPlot(numPointsToPlot, 1), ...
pointsToPlot(numPointsToPlot, 2)] = ...
getTernCoord(compA(i), compB(i));
pointsToPlot(numPointsToPlot, 3) = ECPlotInfo(i, 1);
pointsToPlot(numPointsToPlot, 4) = ECPlotInfo(i, 2);
%if compA(i) < 0.05
if compA(i) < 0.02
numBinPoints = numBinPoints + 1;
binPoints(numBinPoints, 1) = compB(i);
binPoints(numBinPoints, 2) = ECPlotInfo(i, 1);
binPoints(numBinPoints, 3) = ECPlotInfo(i, 2);
end
%if abs(compC(i) - 0.50) < 0.15
if abs(compC(i) - 0.50) < 0.1
numBinPoints2 = numBinPoints2 + 1;
binPoints2(numBinPoints2, 1) = compA(i);
binPoints2(numBinPoints2, 2) = ECPlotInfo(i, 1);
binPoints2(numBinPoints2, 3) = ECPlotInfo(i, 2);
end
end
end
zVals = 1000 * ones(1, size(pointsToPlot, 1));
% surf plot of tafel slope
if ishandle(ECInfo.fTernTafelSurf) == 1
figure(ECInfo.fTernTafelSurf);
clf;
else
ECInfo.fTernTafelSurf = figure;
set(gcf, 'color', 'w');
set(ECInfo.fTernTafelSurf, 'Name', 'Tafel Slope - Surf Plot');
end
axesTernTafel = axes('Units', 'Normalized', ...
'Position', [0.1 0.1 0.8 0.8]);
plotTernBase(axesTernTafel, ternInfo.labels);
plotTernSurf(pointsToPlot(:, 1), pointsToPlot(:, 2), ...
pointsToPlot(:, 3));
colorbar;
hold on;
scatter3(axesTernTafel, pointsToPlot(:, 1), pointsToPlot(:, 2), ...
zVals, 30, 'k', 'filled');
% surf plot of onset potential
if ishandle(ECInfo.fTernOnsetSurf) == 1
figure(ECInfo.fTernOnsetSurf);
clf;
else
ECInfo.fTernOnsetSurf = figure;
set(gcf, 'color', 'w');
set(ECInfo.fTernOnsetSurf, 'Name', 'Onset Potential - Surf Plot');
end
axesTernOnset = axes('Units', 'Normalized', ...
'Position', [0.1 0.1 0.8 0.8]);
plotTernBase(axesTernOnset, ternInfo.labels);
plotTernSurf(pointsToPlot(:, 1), pointsToPlot(:, 2), ...
pointsToPlot(:, 4));
colorbar;
hold on;
scatter3(axesTernOnset, pointsToPlot(:, 1), pointsToPlot(:, 2), ...
zVals, 30, 'k', 'filled');
% scatter plot of tafel slope
if ishandle(ECInfo.fTernTafelScatter) == 1
figure(ECInfo.fTernTafelScatter);
clf;
else
ECInfo.fTernTafelScatter = figure;
set(gcf, 'color', 'w');
set(ECInfo.fTernTafelScatter, 'Name', 'Tafel Slope - Scatter Plot');
end
axesTernTafelScatter = axes('Units', 'Normalized', ...
'Position', [0.1 0.1 0.8 0.8]);
plotTernBase(axesTernTafelScatter, ternInfo.labels);
plotTernScatter(pointsToPlot(:, 1), pointsToPlot(:, 2), ...
pointsToPlot(:, 3), ...
axesTernTafelScatter, 30);
% scatter plot of onset potential
if ishandle(ECInfo.fTernOnsetScatter) == 1
figure(ECInfo.fTernOnsetScatter);
clf;
else
ECInfo.fTernOnsetScatter = figure;
set(gcf, 'color', 'w');
set(ECInfo.fTernOnsetScatter, ...
'Name', 'Onset Potential - Scatter Plot');
end
axesTernOnsetScatter = axes('Units', 'Normalized', ...
'Position', [0.1 0.1 0.8 0.8]);
plotTernBase(axesTernOnsetScatter, ternInfo.labels);
plotTernScatter(pointsToPlot(:, 1), pointsToPlot(:, 2), ...
pointsToPlot(:, 4), ...
axesTernOnsetScatter, 30);
fECPlot.UserData = ECInfo;
end