การระบุสี RGB สำหรับ Eventplot
ส่งค่าสีเป็น list of tuples (r, g, b) ใน parameter color ของ eventplot()
ขั้นตอนหลัก
- ตั้งค่าขนาดรูปและ padding
- สร้าง array 1D pos สำหรับตำแหน่ง events
- สร้าง list ของ color tuple (r, g, b)
- พล็อต parallel lines ด้วย eventplot()
- แสดงผลด้วย show()
ตัวอย่างโค้ด
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
pos = 10 * np.random.random(100)
colors = [(0.75, 0.50, 0.25)]
plt.eventplot(pos, orientation='horizontal',
linelengths=0.75, color=colors)
plt.show()
คำอธิบาย
- ค่า RGB อยู่ในช่วง 0.0 - 1.0
- สามารถเปลี่ยนค่า R, G, B ใน colors เพื่อได้สีต่างๆ
- linelengths ควบคุมความยาวเส้น