File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change 1
1
using RecipesBase
2
2
3
+
3
4
function poly_interval (p:: Poly )
4
5
# Find points of interest
5
6
zero_pts = roots (p)
@@ -10,17 +11,30 @@ function poly_interval(p::Poly)
10
11
# Choose a range that shows all interesting points with some margin
11
12
min_x, max_x = length (pts) > 0 ? (pts[1 ], pts[end ]) : (- 1 , 1 )
12
13
diff = max (max_x - min_x, 1 )
13
- a = min_x - diff
14
- b = max_x + diff
14
+ a = min_x - diff/ 2
15
+ b = max_x + diff/ 2
15
16
16
- return a : diff/ 100 : b
17
+ return a : diff/ 50 : b
17
18
end
18
19
19
- @recipe function poly_recipe (p:: Poly , xs = poly_interval (p))
20
+
21
+ function poly_label (p:: Poly )
20
22
buff = IOBuffer ()
21
23
printpoly (buff, p)
22
- label --> String (take! (buff))
24
+ String (take! (buff))
25
+ end
26
+
27
+
28
+ @recipe function poly_recipe (p:: Poly , range = poly_interval (p))
29
+ label --> poly_label (p)
30
+ range, map (x -> polyval (p, x), range)
31
+ end
32
+
23
33
34
+ @recipe function poly_recipe (p:: Poly , a, b)
35
+ label --> poly_label (p)
36
+ step = (b- a)/ 100
37
+ xs = a: step: b
24
38
ys = map (x -> polyval (p, x), xs)
25
39
xs, ys
26
40
end
You can’t perform that action at this time.
0 commit comments