Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีสร้าง Patch Plot ด้วย Bokeh ใน Python

บทนำ

Patch Plot ใช้แสดงพื้นที่ปิดที่กำหนดโดยลำดับจุด (x, y) เหมาะสำหรับแสดงรูปทรงไม่สม่ำเสมอ

การติดตั้ง

pip3 install bokeh
conda install bokeh

Dependencies

Numpy, Pillow, Jinja2, Packaging, Pyyaml, Six, Tornado, Python-dateutil

ตัวอย่างโค้ด

from bokeh.plotting import figure, output_file, show

p = figure(plot_width=400, plot_height=200)
p.patch(x=[4, 8, 5, 7], y=[2, 3, 5, 2], color="green")
output_file('patchplot.html')
show(p)

คำอธิบาย

  • ระบุพิกัด x และ y ของมุมแต่ละมุม

  • Bokeh จะเชื่อมจุดสุดท้ายกลับไปจุดแรกอัตโนมัติ