-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
56 lines (46 loc) · 1.65 KB
/
plot.py
File metadata and controls
56 lines (46 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import pandas as pd
import matplotlib.pyplot as plt
# Set dark theme style
plt.style.use('dark_background')
# Read the CSV file
df = pd.read_csv('process_schedule.csv')
# Create a figure with dark background
fig, ax = plt.subplots(figsize=(12, 6), facecolor='#1c1c1c')
# High-contrast color palette (add more colors if needed)
high_contrast_colors = [
'#ff0000', '#00ff00', '#ffff00', '#00ffff',
'#ff00ff', '#ffa500', '#7fff00', '#ff69b4',
'#00bfff', '#ffd700'
]
# Plot each process as a horizontal bar
for _, row in df.iterrows():
ax.hlines(y=row['pid'],
xmin=row['start_time'],
xmax=row['end_time'],
linewidth=10,
color=high_contrast_colors[row['pid'] % len(high_contrast_colors)])
# Customize the plot
ax.set_title('Process Schedule Timeline', color='white', fontsize=14, pad=20)
ax.set_xlabel('Time', color='white', fontsize=12)
ax.set_ylabel('Process ID', color='white', fontsize=12)
# Set grid style
ax.grid(True, axis='x', linestyle='--', alpha=0.4, color='#a0a0a0')
# Adjust y-axis
unique_pids = df['pid'].unique()
ax.set_yticks(unique_pids)
ax.tick_params(axis='both', colors='white')
# Create legend with dark background
legend_labels = [f'Process {pid}' for pid in unique_pids]
legend = ax.legend(legend_labels,
bbox_to_anchor=(1.05, 1),
loc='upper left',
facecolor='#2c2c2c',
edgecolor='white',
labelcolor='white')
# Adjust layout and save
plt.tight_layout()
plt.savefig('process_schedule_dark.png',
facecolor=fig.get_facecolor(),
dpi=300,
bbox_inches='tight')
plt.show()