@@ -151,6 +151,7 @@ function plot(samp::Sample;
151
151
legend= :topleft ,
152
152
show_title= true ,
153
153
titlefontsize= 10 ,
154
+ padding:: Number = 0.1 ,
154
155
kw... )
155
156
x, y, ty, xlab, ylab, ylim = prep_plot (samp,channels,num,den,ylim,transformation)
156
157
p = Plots. plot (x,Matrix (ty);
@@ -167,18 +168,21 @@ function plot(samp::Sample;
167
168
end
168
169
Plots. title! (title;titlefontsize= titlefontsize)
169
170
end
170
- dy_ax = collect (Plots. ylims (p))
171
+ if ylim == :auto
172
+ dy_win = collect (Plots. ylims (p))
173
+ else
174
+ buffer = (ylim[2 ]- ylim[1 ])* padding/ 2
175
+ dy_win = (ylim[1 ] + buffer, ylim[2 ] - buffer)
176
+ end
171
177
# plot t0:
172
- Plots. plot! (p,[samp. t0,samp. t0],collect (dy_ax [[1 ,2 ]]);
178
+ Plots. plot! (p,[samp. t0,samp. t0],collect (dy_win [[1 ,2 ]]);
173
179
linecolor= " grey" ,linestyle= :dot ,label= " " )
174
180
# plot selection windows:
175
- dy_dat = [minimum (Matrix (ty)),maximum (Matrix (ty))]
176
- dy = @. (dy_ax + dy_dat)/ 2
177
181
for win in [samp. bwin,samp. swin]
178
182
for w in win
179
183
from = x[w[1 ]]
180
184
to = x[w[2 ]]
181
- Plots. plot! (p,[from,from,to,to,from],collect (dy [[1 ,2 ,2 ,1 ,1 ]]);
185
+ Plots. plot! (p,[from,from,to,to,from],collect (dy_win [[1 ,2 ,2 ,1 ,1 ]]);
182
186
linecolor= " black" ,linestyle= :dot ,label= " " )
183
187
end
184
188
end
@@ -191,12 +195,13 @@ function prep_plot(samp::Sample,
191
195
num:: Union{Nothing,AbstractString} = nothing ,
192
196
den:: Union{Nothing,AbstractString} = nothing ,
193
197
ylim= :auto ,
194
- transformation:: Union{Nothing,AbstractString} = nothing )
198
+ transformation:: Union{Nothing,AbstractString} = nothing ;
199
+ padding:: Number = 0.1 )
195
200
xlab = names (samp. dat)[1 ]
196
201
x = samp. dat[:,xlab]
197
202
meas = samp. dat[:,channels]
198
203
ratsig = isnothing (den) ? " signal" : " ratio"
199
- y = (ratsig == " signal" ) ? meas : formRatios (meas,num,den)
204
+ y = (ratsig == " signal" ) ? meas : formRatios (meas,num,den)
200
205
arg = nothing
201
206
min_val = minimum (Matrix (y))
202
207
if isnothing (transformation)
@@ -209,14 +214,27 @@ function prep_plot(samp::Sample,
209
214
end
210
215
ty = transformeer (y,transformation)
211
216
if ylim == :auto && ratsig == " ratio"
212
- miny = minimum (Matrix (ty))
213
- maxy = maximum (Matrix (ty[x .> samp. t0,:]))
214
- buffer = (maxy- miny)/ 20
215
- ylim = (miny- buffer,maxy+ buffer)
217
+ ylim = get_ylim (samp,channels,num,den,transformation;
218
+ padding= padding)
216
219
end
217
220
return x, y, ty, xlab, ylab, ylim
218
221
end
219
222
export prep_plot
223
+ function get_ylim (samp:: Sample ,
224
+ channels:: AbstractVector ,
225
+ num:: Union{Nothing,AbstractString} = nothing ,
226
+ den:: Union{Nothing,AbstractString} = nothing ,
227
+ transformation:: Union{Nothing,AbstractString} = nothing ;
228
+ padding:: Number = 0.1 )
229
+ dat = windowData (samp,blank= false ,signal= true )
230
+ meas = dat[:,channels]
231
+ ratsig = isnothing (den) ? " signal" : " ratio"
232
+ y = (ratsig == " signal" ) ? meas : formRatios (meas,num,den)
233
+ ty = transformeer (y,transformation)
234
+ miny, maxy = extrema (Matrix (ty))
235
+ buffer = (maxy- miny)* padding
236
+ return (miny- buffer,maxy+ buffer)
237
+ end
220
238
221
239
# minerals
222
240
function plotFitted! (p,
0 commit comments