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

การทำงานกับภาพใน Bokeh (Python)


ใช้เมธอด image_url() และส่งรายการภาพเข้าไป

ขั้นตอน

  • กำหนดค่า output เริ่มต้นเพื่อบันทึกไฟล์เมื่อเรียก show()
  • สร้าง Figure ใหม่สำหรับพล็อต
  • แสดงภาพจาก URL ที่กำหนด
  • แสดง Bokeh object หรือ application ทันที

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

from bokeh.plotting import figure, show, output_file
output_file('image.html')
p = figure(x_range=(0, 1), y_range=(0, 1))
p.image_url(url=['bird.jpg'], x=0, y=1, w=0.8, h=0.6)
show(p)

ผลลัพธ์

การทำงานกับภาพใน Bokeh (Python)