2.1 绘图方法
figure(**kwargs)对象提供多种绘图方法(见1.3节),而这些方法的实现大都基于Bokeh.models接口。本节将展示些基本图形的绘制方法。
代码示例 2-1
1. import numpy as np
2. from bokeh.layouts import gridplot
3. # 数据
4. N = 9
5. x = np.linspace(-2, 2, N)
6. y = x**2
7. sizes = np.linspace(10, 20, N)
8. xpts = np.array([-.09, -.12, .0, .12, .09])
9. ypts = np.array([-.1, .02, .1, .02, -.1])
10. # 画布列表
11. figures = []
12. p = figure(title="annular_wedge")
13. p.annular_wedge(x, y, 10, 20, 0.6, 4.1, color="#8888ee",
14. inner_radius_units="screen", outer_radius_units="screen")
15. figures.append(p)
16. p = figure(title="annulus")
17. p.annulus(x, y, 10, 20, color="#7FC97F",
18. inner_radius_units="screen", outer_radius_units = "screen")
19. figures.append(p)
20. p = figure(title="arc")
21. p.arc(x, y, 20, 0.6, 4.1,
22. radius_units="screen", color="#BEAED4", line_width=3)
23. figures.append(p)
24. p = figure(title="bezier")
25. p.bezier(x, y, x+0.2, y, x+0.1, y+0.1, x-0.1, y-0.1,
26. color="#D95F02", line_width=2)
27. figures.append(p)
28. p = figure(title="circle")
29. p.circle(x, y, radius=0.1, color="#3288BD")
30. figures.append(p)
31. p = figure(title="ellipse")
32. p.ellipse(x, y, 15, 25, angle=-0.7, color="#1D91C0&