in scripts/figs.py [0:0]
def draw_reorg():
dfs = {
"Redistribution cost unaware": pd.read_csv("../long_term/placement_unaware.csv"),
"Moirai": pd.read_csv("../long_term/placement_moirai.csv"),
}
fig, ax = plt.subplots(figsize=(11, 5))
# Define line styles and markers for black-and-white friendly plotting
line_styles = ['--', '--', '-', '-']
# Placeholder for cumulative data
cumulative_data = {
"Redistribution cost unaware (Ingress)": [],
"Redistribution cost unaware (Egress)": [],
"Moirai (Ingress)": [],
"Moirai (Egress)": []
}
for label, df in dfs.items():
# Convert Ingress and Egress to bytes
df['Ingress_Bytes'] = df['Ingress'].apply(parse_size).cumsum()
df['Egress_Bytes'] = df['Egress'].apply(parse_size).cumsum()
cumulative_data[f"{label} (Ingress)"] = df['Ingress_Bytes']
cumulative_data[f"{label} (Egress)"] = df['Egress_Bytes']
# Plot the Ingress and Egress data
ax.plot(df['On-premises'], df['Ingress_Bytes'], label=f'{label} (ingress)',
linestyle=line_styles.pop(0), color='blue', linewidth=2, marker='x', markersize=12)
ax.plot(df['On-premises'], df['Egress_Bytes'], label=f'{label} (egress)',
linestyle=line_styles.pop(0), color='green', linewidth=2, marker='*', markersize=12)
if label == "Redistribution cost unaware":
best_case_x = df['On-premises']
best_case_y = (1 - df['On-premises'] / 100) * (299.12 * 1024 ** 5)
ax.plot(best_case_x, best_case_y, 'r-', label='Best case (ingress)', linewidth=6)
# Customize the plot
ax.set_xlabel('On-premises Storage Space / Total Data Size (%)', fontsize=font_size)
ax.set_ylabel('Traffic Volume (PB)', fontsize=font_size)
ax.tick_params(axis='x', labelsize=font_size - 2)
ax.tick_params(axis='y', labelsize=font_size - 2)
ax.grid(True)
# Add legend
ax.legend(loc='upper center',
bbox_to_anchor=(0.5, 1.35), fontsize=font_size - 2,
ncol=2, frameon=False)
# Set y-axis ticks and labels
ticks = [x for x in range(0, 55, 5)]
yticks = [i * 10 * 1024 ** 5 for i in ticks]
ytick_labels = ["0"] + [f"{i * 10}" if i % 2 == 0 else "" for i in ticks[1:]]
ax.set_ylim(ymax=450 * 1024 ** 5)
ax.set_yticks(yticks)
ax.set_yticklabels(ytick_labels, fontsize=font_size - 2)
ax.set_xlim(0, 90)
ax.set_xticks([90, 80, 70, 60, 50, 40, 30, 20, 10, 0])
ax.set_xticklabels(["90%", "80%", "70%", "60%", "50%", "40%", "30%", "20%", "10%", "0%"], fontsize=font_size - 2)
# Invert x-axis to start from large to low
ax.invert_xaxis()
plt.tight_layout()
plt.savefig('migration.pdf', bbox_inches='tight')