-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChangeXAxisLabels.sci
89 lines (62 loc) · 2.59 KB
/
ChangeXAxisLabels.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
ModuleName="ChangeXAxisLabels";
Version="0.01";
DateModified="13-Apr-2015";
DateOfCreation="13-Apr-2015";
Author="Rob Eccleston";
Description="Changes X 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)
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=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