-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisualizer.py
63 lines (56 loc) · 1.87 KB
/
visualizer.py
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
57
58
59
60
61
62
63
import plotly.express as px
import plotly.graph_objects as go
def create_performance_chart(df):
"""
Create an interactive performance chart using plotly
"""
# Create figure with secondary y-axis
fig = go.Figure()
# Add traces for each bit length - Actual Performance
for bit_length in sorted(df['Code Bit Length'].unique()):
df_bit = df[df['Code Bit Length'] == bit_length]
# Actual performance (without dictionary)
fig.add_trace(go.Scatter(
x=df_bit['Max Dictionary Size'],
y=df_bit['Compression Performance (%)'],
mode='lines+markers',
name=f'{bit_length} bits (Actual)',
line=dict(dash='solid')
))
# Theoretical performance (with dictionary)
fig.add_trace(go.Scatter(
x=df_bit['Max Dictionary Size'],
y=df_bit['Compression Performance with Dict (%)'],
mode='lines+markers',
name=f'{bit_length} bits (With Dict)',
line=dict(dash='dot')
))
# Update layout
fig.update_layout(
title='Compression Performance by Dictionary Size',
xaxis_title='Dictionary Size',
yaxis_title='Compression Performance (%)',
hovermode='x unified',
showlegend=True,
legend_title='Code Bit Length',
# Add a horizontal line at y=0 to show where compression becomes expansion
shapes=[
dict(
type='line',
yref='y',
y0=0,
y1=0,
xref='paper',
x0=0,
x1=1,
line=dict(
color='red',
width=1,
dash='dash'
)
)
]
)
# Update axes
fig.update_xaxes(type='log', tickformat=',d')
return fig