ylim
Builtin index · Plotting
xlim(lo, hi)
Input: lo, hi · Output: no output
What it is
Fixes an axis range from lo, hi (numbers, data units). After yyaxis right these apply to the right-hand axis.
Overloads
One call shape — this function is not overloaded.
Code Input Output Description
xlim(lo, hi)lo number not documented yet
hi number not documented yet
no output After yyaxis right these apply to the right-hand axis.
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
function frame (i)
t = 2 * pi * i / 60
x = (0 to 200 ) / 20
plot (x, sin (x - t), color = "royalblue" )
ylim (-1.2 , 1.2 )
axis off
end function
animate ("frame" , 60 , "wave.svg" , fps = 24 )
not run by the build — this one needs something the repository cannot supply · from plotting
# A square canvas, so that equal ranges really are equal scales and the
# circle below comes out round. Without it the figure would render an
# ellipse while the paragraph above it explained how to avoid one.
figure_size (560 , 560 )
xlim (-2 , 2 )
ylim (-2 , 2 )
axis equal
circle (0 , 0 , 1 , color = "royalblue" , fill = "royalblue" )
ellipse (0 , 0 , 1.6 , 0.7 , color = "crimson" , rotate = 30 )
arc (0 , 0 , 1.3 , 0 , 120 , color = "seagreen" , width = 2 )
polygon ([0.8 , 1.6 , 1.2 ], [-1.6 , -1.6 , -0.9 ], color = "purple" , fill = "plum" )
rectangle (-1.8 , -1.8 , -1.2 , -1.2 , color = "orange" )
rect (1.0 , -1.8 , 1.8 , -1.2 , color = "teal" )
point (0 , 1.9 )
-2.0
-1.5
-1.0
-0.5
0
0.5
1.0
1.5
2.0
-2.0
-1.5
-1.0
-0.5
0
0.5
1.0
1.5
2.0
(0, 1.9)
from plotting
fs = 1000
b = butter (4 , "low" , 100 , fs)
h = freqz (b, 512 )
f = linspace (0 , fs / 2 , 512 )
plot (f, mag2db (abs (h)), color = "#4169e1" , width = 2 )
xscale ("log" )
ylim (-80 , 5 )
xlabel ("frequency (Hz)" )
ylabel ("magnitude (dB)" )
title ("4th-order Butterworth, 100 Hz cutoff" )
output · plot: figure 8 (512 points)
-80
-60
-40
-20
0
0
150
300
450
Magnitude Response
Frequency (Hz)
Magnitude (dB)
-150
-100
-50
0
50
100
150
0
150
300
450
Phase Response
Frequency (Hz)
Phase (deg)
-250
-200
-150
-100
-50
0
0
150
300
450
Group Delay
Frequency (Hz)
Delay (samples)
-120
-80
-40
0
40
10 −272
10 −204
10 −136
10 −68
10 0
x=-0.135, y=0.991
x=-0.135, y=-0.991
x=0.57, y=0.821
x=0.57, y=-0.821
4th-order Butterworth, 100 Hz
cutoff
frequency (Hz)
magnitude (dB)
from signal-processing
Xc = randn (200 , 2 , seed = 41 )
yc = zeros (200 )
for i in 0 to 199
if Xc[i, 0 ] + Xc[i, 1 ] > 0
yc[i] = 1
end if
end for
s = train_test_split (Xc, yc, test_size = 0.3 , seed = 9 )
function accuracy (model)
yhat = model.predict (s.X_test)
hit = yhat == s.y_test
return len (yhat[hit]) / len (yhat)
end function
names = ("knn" , "tree" , "forest" , "bayes" )
scores = (
accuracy (knn_model (s.X_train, s.y_train, 5 , kind = "classification" )),
accuracy (tree_model (s.X_train, s.y_train, kind = "classification" )),
accuracy (random_forest_model (s.X_train, s.y_train, 40 , seed = 3 , kind = "classification" )),
accuracy (naive_bayes_model (s.X_train, s.y_train))
)
for i in 0 to 3
print ("{names[i]}: {round(scores[i], 3)}" )
end for
bar (0 to 3 , scores, color = "#4169e1" , values = true )
xticks (0 to 3 )
xticklabels (names)
ylim (0 , 1 )
ylabel ("test accuracy" )
title ("held-out accuracy, same split" )
output knn: 0.983
tree: 0.95
forest: 0.967
bayes: 0.917
· bar: figure 10 (4 points)
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1.0
knn
tree
forest
bayes
x=-1.058, y=-0.826
x=0.594, y=0.636
x=0.88, y=1.305
x=-0.379, y=-0.489
x=0.152, y=1.215
x=1.407, y=0.754
x=0.231, y=-0.942
x=-1.291, y=-0.12
x=-0.085, y=-0.627
x=0.304, y=-0.101
x=0.037, y=0.004
x=-0.705, y=-0.429
x=0.241, y=-0.559
x=-0.582, y=-1.167
x=-0.277, y=-0.685
x=-1.636, y=-1.342
x=-0.865, y=-0.799
x=0.131, y=0.029
x=-1.581, y=-1.773
x=-2.048, y=-2.111
x=2.947, y=2.32
x=-0.456, y=-1.875
x=0.908, y=0.097
x=0.85, y=1.1
x=0.517, y=0.032
x=0.003, y=0.246
x=-0.201, y=0.212
x=0.466, y=-0.074
x=0.426, y=1.096
x=-0.066, y=-0.164
x=1.021, y=1.029
x=0.113, y=0.035
x=-0.998, y=-0.494
x=-0.066, y=-0.991
x=2.823, y=0.731
x=-0.046, y=-0.746
x=-0.029, y=-0.9
x=-0.031, y=0.196
x=-0.616, y=0.539
x=-1.349, y=-0.313
x=-1.085, y=-1.65
x=-1.452, y=-1.608
x=0.973, y=0.867
x=0.737, y=0.242
x=-0.185, y=0.468
x=1.175, y=1.485
x=-1.836, y=-0.822
x=-0.157, y=-0.076
x=0.407, y=0.307
x=-1.365, y=-1.022
x=-0.847, y=1.143
x=-0.762, y=0.021
x=-1.044, y=-0.505
x=0.478, y=1.123
x=0.316, y=-0.102
x=0.965, y=0.825
x=-0.751, y=-0.957
x=-0.988, y=-0.033
x=-1.22, y=-0.385
x=-0.681, y=-0.432
x=-0.621, y=0.256
x=0.918, y=0.744
x=1.182, y=-0.477
x=-0.039, y=0.425
x=0.585, y=-0.031
x=0.297, y=-0.535
x=0.112, y=-0.357
x=0.039, y=0.8
x=0.16, y=0.201
x=1.261, y=-0.955
x=0.95, y=0.238
x=-0.013, y=0.393
x=-1.577, y=-0.343
x=-0.67, y=-0.101
x=-0.631, y=-1.302
x=-0.84, y=-0.949
x=1.692, y=0.99
x=0.389, y=0.473
x=-0.261, y=-0.509
x=-0.491, y=-0.033
x=0.634, y=0.806
x=-0.342, y=0.622
x=-1.674, y=-1.63
x=0.039, y=-0.203
x=0.175, y=-0.688
x=0.206, y=0.293
x=1.405, y=0.994
x=-0.644, y=-0.672
x=-0.623, y=-0.7
x=1.569, y=0.384
x=-0.533, y=-0.154
x=0.682, y=-0.014
x=1.089, y=1.13
x=0.342, y=0.984
x=1.161, y=0.991
x=-0.232, y=0.289
x=-0.607, y=-0.737
x=0.295, y=0.07
x=0.275, y=0.25
x=-1.141, y=-0.456
x=0.461, y=0.554
x=-0.671, y=-0.906
x=0.513, y=1.154
x=0.499, y=-0.224
x=1.753, y=1.474
x=0.103, y=0.61
x=-0.351, y=0.258
x=0.553, y=-0.788
x=0.298, y=0.904
x=0.472, y=0.843
x=-0.94, y=-0.939
x=-1.062, y=-1.629
x=0.467, y=0.806
x=-0.653, y=-1.083
x=1.172, y=1.15
x=0.206, y=0.15
x=-1.077, y=-0.827
x=0.153, y=-0.987
x=0.202, y=0.439
x=0.011, y=-0.385
x=-0.67, y=0.029
x=1.367, y=0.502
x=0.955, y=0.531
x=0.352, y=0.238
x=1.543, y=0.703
x=-1.029, y=-0.474
x=0.104, y=0.508
x=0.877, y=-0.209
x=-1.366, y=-1.921
x=-1.583, y=-1.15
x=1.748, y=0.901
x=0.359, y=0.563
x=0.309, y=-0.002
x=1.322, y=1.929
x=-0.57, y=-0.79
x=-0.857, y=0.127
x=0.177, y=-0.37
x=-1.161, y=-1.563
x=0.371, y=1.281
x=-0.811, y=-1.39
x=0.168, y=1.089
x=-0.599, y=0.823
x=-0.452, y=-1.067
x=-1.241, y=-1.344
x=-0.711, y=-0.72
x=-0.233, y=-0.53
x=-0.344, y=0.761
x=1.152, y=0.27
x=0.989, y=0.896
x=0.308, y=0.67
x=-1.851, y=-1.723
x=0.866, y=0.926
x=-0.586, y=0.32
x=-0.204, y=-0.76
x=1.617, y=1.863
x=-0.897, y=-1.095
x=1.375, y=0.119
x=0.027, y=0.911
x=-0.268, y=-0.958
x=-0.58, y=-0.581
x=1.263, y=0.222
x=0.021, y=0.109
x=0.228, y=-0.664
x=0.002, y=-0.26
x=-0.301, y=0.237
x=0.646, y=0.863
x=0.272, y=-1.038
x=-0.432, y=-0.686
x=-0.123, y=1.22
x=0.844, y=1.163
x=-1.237, y=-1.157
x=2, y=1.132
x=-0.836, y=0.309
x=-0.332, y=-0.738
x=0.17, y=0.198
x=-0.327, y=0.587
x=-1.737, y=-1.131
x=-0.054, y=0.877
x=0.317, y=0.75
x=-1.406, y=-1.905
x=0.04, y=0.092
x=1.456, y=0.878
x=0.373, y=0.985
x=-0.912, y=-0.551
x=-0.104, y=0.042
x=0.349, y=0.549
x=1.098, y=0.24
x=0.588, y=-0.011
x=-0.164, y=-0.854
x=0.235, y=-0.679
x=-0.713, y=0.139
x=0.252, y=-0.404
x=-0.029, y=-0.281
x=-0.988, y=-0.818
x=0.223, y=-0.99
x=-0.591, y=0.839
x=-0.36, y=-0.088
x=-0.006, y=-0.156
x=-0.054, y=-0.158
x=0.644, y=-0.111
x=-3, y=-4.018
x=-2.75, y=-6.388
x=-2.5, y=-5.262
x=-2.25, y=0.293
x=-2, y=1.587
x=-1.75, y=1.194
x=-1.5, y=1.829
x=-1.25, y=2.719
x=-1, y=-0.145
x=-0.75, y=0.779
x=-0.5, y=-0.837
x=-0.25, y=2.101
x=0, y=0.378
x=0.25, y=1.148
x=0.5, y=1.019
x=0.75, y=-3.978
x=1, y=-3.731
x=1.25, y=-0.191
x=1.5, y=-1.178
x=1.75, y=-2.55
x=2, y=-0.452
x=2.25, y=4.657
x=2.5, y=0.591
x=2.75, y=5.418
x=3, y=6.826
x=-4.221, y=-3.675
x=-4.749, y=-4.599
x=-4.378, y=-5.049
x=-4.908, y=-2.938
x=-3.111, y=-4.705
x=-4.7, y=-3.185
x=-4.948, y=-4.24
x=-5.087, y=-4.991
x=-3.755, y=-2.658
x=-4.866, y=-3.893
x=-3.202, y=-4.799
x=-3.536, y=-4.59
x=-4.643, y=-4.655
x=-4.223, y=-3.8
x=-4.771, y=-4.791
x=-5.162, y=-3.624
x=-2.644, y=-3.501
x=-5.565, y=-4.823
x=-3.561, y=-2.64
x=-4.529, y=-4.524
x=-5.6, y=-5.042
x=-3.048, y=-3.184
x=-4.283, y=-4.206
x=-5.239, y=-4.032
x=-2.871, y=-5.062
x=-2.117, y=-2.96
x=-3.794, y=-3.873
x=-3.245, y=-4.153
x=-4.242, y=-4.691
x=-3.935, y=-4.681
x=-2.991, y=-2.757
x=-4.498, y=-3.651
x=-4.482, y=-5.712
x=-3.324, y=-4.723
x=-5.062, y=-5.077
x=-4.34, y=-4.914
x=-4.945, y=-5.731
x=-4.523, y=-3.545
x=-2.907, y=-3.457
x=-4.38, y=-3.659
x=3.22, y=4.412
x=3.089, y=4.062
x=2.827, y=3.584
x=3.848, y=5.345
x=4.196, y=4.669
x=3.111, y=4.336
x=2.961, y=3.91
x=5.036, y=4.596
x=5.339, y=4.031
x=4.874, y=2.505
x=4.357, y=2.791
x=3.318, y=5.241
x=2.544, y=3.948
x=6.731, y=3.889
x=4.101, y=4.456
x=3.18, y=2.902
x=4.415, y=7.292
x=3.9, y=6.008
x=3.342, y=4.252
x=2.138, y=4.074
x=3.304, y=4.752
x=4.53, y=4.152
x=3.264, y=4.913
x=3.885, y=2.94
x=5.542, y=3.917
x=1.488, y=3.061
x=2.847, y=3.236
x=3.93, y=3.488
x=2.913, y=2.598
x=3.839, y=4.13
x=2.508, y=3.961
x=2.846, y=4.195
x=4.278, y=4.197
x=4.971, y=5.339
x=4.568, y=5.297
x=3.797, y=3.895
x=3.459, y=4.494
x=4.285, y=3.369
x=3.836, y=2.999
x=2.123, y=1.312
x=-0.678, y=-0.737
x=-0.734, y=0.333
x=-0.016, y=1.204
x=0.605, y=0.633
x=0.426, y=-0.995
x=-0.383, y=0.403
x=-0.064, y=0.253
x=-1.862, y=-0.361
x=0.298, y=0.52
x=-1.481, y=-1.025
x=0.719, y=0.808
x=1.151, y=-0.726
x=-0.082, y=-0.357
x=-0.401, y=0.791
x=-0.182, y=0.737
x=0.394, y=0.021
x=0.954, y=0.671
x=0.405, y=0.336
x=-1.617, y=-0.65
x=-0.669, y=-1.147
x=-2.452, y=1.586
x=1.709, y=-0.65
x=0.122, y=-0.171
x=1.066, y=-1.195
x=0.053, y=-0.57
x=-0.396, y=-0.235
x=0.819, y=-0.788
x=0.012, y=0.012
x=-2.723, y=0.397
x=1.545, y=0.484
x=-1.119, y=0.98
x=-0.22, y=-0.804
x=-1.564, y=-1.293
x=-1.811, y=-0.276
x=0.774, y=-1.055
x=0.575, y=1.214
x=-0.348, y=-1.078
x=0.015, y=-0.404
x=0.245, y=-1.466
x=0.436, y=1.71
x=0, y=0.983
0.983
x=1, y=0.95
0.95
x=2, y=0.967
0.967
x=3, y=0.917
0.917
held-out accuracy, same split
a
test accuracy
measured
cubic fit
measured
forecast
cluster 0
cluster 1
cluster 2
centroids
from statistics-ml
See also
xlim — documented in the same entry.