-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChangeAxisLabels.sci
92 lines (65 loc) · 2.68 KB
/
ChangeAxisLabels.sci
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
ModuleName="ChangeAxisLabels";
Version="0.01";
DateModified="30-Apr-2015";
DateOfCreation="13-Apr-2015";
Author="Rob Eccleston";
Description="Changes axis labels to those given in the array passed to the function ..
Needs to be passed an array of strings the same length as the number of ..
data points that have been plotted. Function should be called immediately ..
after plot command is used";
mprintf("Loading " + ModuleName + " V" + Version + ", Last Modified: " + DateModified + "\n");
function ChangeXAxisLabels(NewLabels)
if size(NewLabels,2)>size(NewLabels,1)
NewLabels=NewLabels';
end
a=gca()
tickdata=a.x_ticks.labels
tickindex=strtod(strsubst(tickdata, " ", ""))
tickindex=tickindex(2:$)
MaxNumberOfSamples=size(a.children(1).children(1).data,1)
OutOfBoundsValues=find(tickindex>MaxNumberOfSamples)
tickindex(OutOfBoundsValues)=MaxNumberOfSamples
XAxisValues=string(NewLabels(tickindex,1))
XAxisValues(OutOfBoundsValues)=""
XAxisValues = [ "Start"; XAxisValues]
a.x_ticks.labels=XAxisValues
endfunction
function ChangeYAxisLabels(NewLabels)
a=gca()
tickdata=a.y_ticks.labels
tickindex=strtod(strsubst(tickdata, " ", ""))
tickindex=tickindex(2:$)
MaxNumberOfSamples=size(a.children(1).children(1).data,1)
OutOfBoundsValues=find(tickindex>MaxNumberOfSamples)
tickindex(OutOfBoundsValues)=MaxNumberOfSamples
XAxisValues=NewLabels(tickindex,1)
XAxisValues(OutOfBoundsValues)=""
XAxisValues = [ "Start"; XAxisValues]
a.x_ticks.labels=XAxisValues
endfunction
function ChangeXAxisLabelsSurf(NewLabels)
a=gca()
tickdata=a.x_ticks.labels
tickindex=strtod(strsubst(tickdata, " ", ""))
tickindex=tickindex(2:$)
MaxNumberOfSamples=size(unique(a.children(1).data.x),1)
OutOfBoundsValues=find(tickindex>MaxNumberOfSamples)
tickindex(OutOfBoundsValues)=MaxNumberOfSamples
XAxisValues=NewLabels(tickindex,1)
XAxisValues(OutOfBoundsValues)=""
XAxisValues = [ "Start"; XAxisValues]
a.x_ticks.labels=XAxisValues
endfunction
function ChangeYAxisLabelsSurf(NewLabels)
a=gca()
tickdata=a.y_ticks.labels
tickindex=strtod(strsubst(tickdata, " ", ""))
tickindex=tickindex(2:$)
MaxNumberOfSamples=size(unique(a.children(1).data.y),1)
OutOfBoundsValues=find(tickindex>MaxNumberOfSamples)
tickindex(OutOfBoundsValues)=MaxNumberOfSamples
YAxisValues=NewLabels(tickindex,1)
YAxisValues(OutOfBoundsValues)=""
YAxisValues = [ "Start"; YAxisValues]
a.y_ticks.labels=YAxisValues
endfunction