-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscanplot.m
More file actions
138 lines (125 loc) · 4.98 KB
/
Copy pathscanplot.m
File metadata and controls
138 lines (125 loc) · 4.98 KB
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
131
132
133
134
135
136
137
138
function scanplot(varargin)
% SCANPLOT Called by specr to plot scans.
%
% Copyright 2009, Zhang Jiang
hFigSpecr = findall(0,'Tag','specr_Fig');
hPopupmenuX = findall(hFigSpecr,'Tag','specr_PopupmenuX');
hPopupmenuY = findall(hFigSpecr,'Tag','specr_PopupmenuY');
hPopupmenuPlotStyle = findall(hFigSpecr,'Tag','specr_PopupmenuPlotStyle');
hAxes = findall(hFigSpecr,'Tag','specr_Axes');
settings = getappdata(hFigSpecr,'settings');
file = settings.file;
scan = settings.scan;
if isempty(file) | isempty(scan) | ~isfield(scan,'selection') | isempty(scan.selection{1})
return;
end
% --- set x, y axis labels
popupmenuXString = get(hPopupmenuX,'String');
popupmenuYString = get(hPopupmenuY,'String');
popupmenuXValue = get(hPopupmenuX,'Value');
popupmenuYValue = get(hPopupmenuY,'Value');
set(get(hAxes,'XLabel'),'String',popupmenuXString(popupmenuXValue));
set(get(hAxes,'YLabel'),'String',popupmenuYString(popupmenuYValue));
cla(hAxes);
hLine = [];
colorSpec = {'b';'r';'g';'c';'m';'k'};
markerSpec = {'o';'s';'d';'^';'v';'<';'>'};
% markerFaceColorSpec = varycolor(32);
% markerFaceColorSpec = markerFaceColorSpec(randperm(32),:);
markerFaceColorSpec = {'m';'b';'k';'r';'c';'g'};
for iSelection = 1:length(scan.selection)
% --- if ydata has negative data,then ydataError = 0
if isempty(find( scan.selection{iSelection}.colData(:,popupmenuYValue)<0 ))
% --- statistical error
ydataError = ...
sqrt(scan.selection{iSelection}.colData(:,popupmenuYValue));
else
ydataError = ...
zeros(length(scan.selection{iSelection}.colData(:,popupmenuYValue)),1);
end
hLine(iSelection) = line('Parent',hAxes,...
'XData',scan.selection{iSelection}.colData(:,popupmenuXValue),...
'YData',scan.selection{iSelection}.colData(:,popupmenuYValue),...
'Tag',['specrScan',num2str(scan.selectionNumber(iSelection))]);
set(hLine(iSelection),...
'color',colorSpec{mod(iSelection-1,length(colorSpec))+1},...
'marker',markerSpec{mod(iSelection-1,length(markerSpec))+1},...
'markerfacecolor',markerFaceColorSpec{mod(iSelection-1,length(markerFaceColorSpec))+1});
% set(hLine(iSelection),...
% 'color',colorSpec{mod(iSelection-1,length(colorSpec))+1},...
% 'marker',markerSpec{mod(iSelection-1,length(markerSpec))+1},...
% 'markerfacecolor',markerFaceColorSpec(mod(iSelection-1,length(markerFaceColorSpec))+1,:));
setappdata(hLine(iSelection),'ydataError',ydataError);
end
set(hLine,...
'LineStyle','-',...
'MarkerSize',5);
% set(hLine,...
% 'Color','b',...
% 'LineStyle','-',...
% 'Marker','o',...
% 'MarkerSize',5,...
% 'MarkerFaceColor','m');
% --- determine whether to fix xlim for a monitor scan
% fix xlim only when the first column is selected and it is not a time scan
% nor a hklscan
if ~isempty(timerfindall('Tag','timerMonitor')) ...
&& settings.monitorErasemode == 1 ...
&& popupmenuXValue == 1 ...
&& isempty(findstr(lower(scan.head{end}),' timescan')) ...
&& isempty(findstr(lower(scan.head{end}),' xpcsscan')) ...
&& isempty(findstr(lower(scan.head{end}),' hklscan'))
a = scan.head{end};
b = findstr(a,' ');
c = diff(b);
for ii = length(c):-1:1
if c(ii)==1
a(b(ii)) = [];
end
end
b = findstr(a,' ');
xlims = sort([str2double(a(b(4)+1:b(5)-1)), str2double(a(b(5)+1:b(6)-1))]);
xlims = [xlims(1)-(xlims(2)-xlims(1))*0.05-eps, xlims(2)+(xlims(2)-xlims(1))*0.05+eps];
set(hAxes,'xlim',xlims);
else
set(hAxes,'xlimmode','auto');
end
% --- set title
[filepath,filename,fileext] = fileparts(file);
% construct scan str
b={};
b{1,1} = scan.selectionNumber(1);
for ii=2:length(scan.selectionNumber)
if scan.selectionNumber(ii)-scan.selectionNumber(ii-1) == 1
b{end,1} = [b{end,1},scan.selectionNumber(ii)];
else
b{end+1,1} = scan.selectionNumber(ii);
end
end
scanStr = '';
for ii=1:length(b)
if length(b{ii})>1
tmp_str = [num2str(b{ii}(1)),'-',num2str(b{ii}(end))];
else
tmp_str = num2str(b{ii});
end
scanStr = [scanStr,' ',tmp_str];
end
scanStr(1) = '';
% construct title str
title_str = {...
['File: ',titlestr(filename),', Scan ',scanStr,', ',scan.selection{end}.time];...
[scan.head{scan.selectionIndex(end)}(length(num2str(scan.selectionNumber(end)))+5:end)]...
};
set(get(hAxes,'Title'),'String',title_str);
%--- calculate Peak, COM, and FWHM and label plot
[scanPeak,scanCOM,scanFWHM] = params(...
scan.selection{end}.colData(:,[popupmenuXValue,popupmenuYValue]));
xlabelStr = {scan.selection{end}.colHead{get(hPopupmenuX,'Value')};...
' ';...
['Peak ',num2str(scanPeak.Y),' @ ',num2str(scanPeak.X),...
', COM ',num2str(scanCOM),...
', FWHM ',num2str(scanFWHM.FWHM),' @ ',num2str(scanFWHM.center)]};
set(get(hAxes,'XLabel'),'String',xlabelStr);
% --- determine legend
curvelegend(hFigSpecr);