-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
47 lines (38 loc) · 2.24 KB
/
plot.py
File metadata and controls
47 lines (38 loc) · 2.24 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
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
# Read the CSV file
df = pd.read_csv('E2E_time_results.csv')
# df = pd.read_csv('Kernel_time_results.csv') # Uncomment this line if needed to switch to the other file
# Create a figure and a set of subplots with a specific size
fig, ax1 = plt.subplots(figsize=(12, 8)) # Renamed ax to ax1 for clearer distinction of primary and secondary Y-axes
# Plot the execution times
line1 = ax1.plot(df['pixels'], df['my_time_s'], 'b-', linewidth=2, label='Ours (Left Axis)')
line2 = ax1.plot(df['pixels'], df['opencv_time_s'], 'r-', linewidth=2, label='OpenCV (Left Axis)')
# Format the primary plot
ax1.set_xlabel('Pixels', fontsize=20)
ax1.set_ylabel('Execution Time (seconds)', fontsize=20, color='k') # Color of the primary Y-axis label
ax1.tick_params(axis='y', labelcolor='k')
ax1.grid(True, linestyle='--', alpha=0.7)
# Create a second Y-axis sharing the same X-axis (for speedup)
ax2 = ax1.twinx()
line3 = ax2.plot(df['pixels'], df['speedup'], color='g', linestyle='--', linewidth=2, label='Speedup (Right Axis)')
ax2.set_ylabel('Speedup', fontsize=20) # Color of the secondary Y-axis label matches the line color
ax2.tick_params(axis='y') # Color of the secondary Y-axis tick labels matches the line color
# Combine legends
# Get lines and labels from both axes
lines = line1 + line2 + line3
labels = [l.get_label() for l in lines]
# Place the legend in a location that is less likely to obscure the data, e.g., the upper left corner
ax1.legend(lines, labels, loc='upper left', fontsize=16) # Adjusted legend font size and position
# # Add text describing the average speedup
# avg_speedup = df['speedup'].mean()
# # Adjust text position to avoid overlap with the right Y-axis or legend
# fig.text(0.5, 0.05, f'Average Speedup: {avg_speedup:.2f}', ha='center', fontsize=20,
# bbox=dict(facecolor='white', alpha=0.8, boxstyle='round,pad=0.5'))
# Uncomment the following line if there was a suptitle previously
# fig.suptitle('Performance Comparison: My Implementation vs OpenCV with Speedup', fontsize=20)
# Save the figure
plt.savefig('E2E_time_benchmark_comparison_with_speedup.pdf', bbox_inches='tight')
# plt.savefig('Kernel_time_benchmark_comparison_with_speedup.pdf', bbox_inches='tight')
plt.show()