บทนำ
Bokeh เหมาะสำหรับพลอตฟังก์ชันคณิตศาสตร์แบบโต้ตอบ รองรับ NumPy สำหรับสร้างข้อมูล
การติดตั้ง
pip3 install bokeh conda install bokeh
Dependencies
Numpy, Pillow, Jinja2, Packaging, Pyyaml, Six, Tornado, Python-dateutil
ตัวอย่างโค้ด
from bokeh.plotting import figure, output_file, show
import numpy as np
import math
x = np.arange(0, math.pi * 4, 0.1)
y = np.sin(x)
output_file("sample.html")
p = figure(title="A simple sine wave", x_axis_label='x', y_axis_label='y')
p.line(x, y, legend_label="sine", line_width=2)
show(p)คำอธิบาย
สร้าง x ด้วย
np.arangeครอบ 4πคำนวณ y = sin(x)
ใช้
lineพร้อม legend และ line_width