Skip to content

Commit 2c44fad

Browse files
committed
feat(vis): increase animation FPS and rotation smoothness
1 parent 2e6852d commit 2c44fad

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

src/visualization.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,12 @@ def update(frame):
213213
ax.view_init(elev=20, azim=frame)
214214
return (fig,)
215215

216-
ani = FuncAnimation(fig, update, frames=np.arange(0, 360, 2), interval=50)
216+
ani = FuncAnimation(fig, update, frames=np.arange(0, 360, 2), interval=40)
217217

218218
if save_path:
219219
if save_path.endswith(".gif"):
220220
print("Generating 3D animation (GIF)... this may take a moment.")
221-
ani.save(save_path, writer="pillow", fps=20)
221+
ani.save(save_path, writer="pillow", fps=25)
222222
else:
223223
plt.savefig(save_path)
224224

@@ -508,11 +508,11 @@ def update(frame):
508508
ax.view_init(elev=20, azim=frame)
509509
return (fig,)
510510

511-
ani = FuncAnimation(fig, update, frames=np.arange(0, 360, 4), interval=50)
511+
ani = FuncAnimation(fig, update, frames=np.arange(0, 360, 2), interval=40)
512512

513513
if save_path:
514514
if save_path.endswith(".gif"):
515-
ani.save(save_path, writer="pillow", fps=15)
515+
ani.save(save_path, writer="pillow", fps=25)
516516
else:
517517
plt.savefig(save_path)
518518

@@ -787,7 +787,7 @@ def plot_two_variants_comparison_3d(
787787
fig = plt.figure(figsize=(20, 9))
788788
ax1 = fig.add_subplot(121, projection="3d")
789789
ax2 = fig.add_subplot(122, projection="3d")
790-
790+
791791
# Define color palette
792792
c_ref = "#333333"
793793
c1 = "#1f77b4"
@@ -812,7 +812,7 @@ def format_label(name, m_dict):
812812
alpha=0.25,
813813
zorder=1,
814814
)
815-
815+
816816
label1 = format_label(name1, metrics_dict1)
817817
ax1.scatter(
818818
metrics1["Return"],
@@ -847,7 +847,7 @@ def format_label(name, m_dict):
847847
alpha=0.25,
848848
zorder=1,
849849
)
850-
850+
851851
label2 = format_label(name2, metrics_dict2)
852852
ax2.scatter(
853853
metrics2["Return"],
@@ -869,19 +869,23 @@ def format_label(name, m_dict):
869869
ax2.legend(loc="upper left", frameon=True, shadow=True, fontsize=10)
870870
ax2.view_init(elev=25, azim=45)
871871

872-
plt.suptitle("3D Pareto Front Quality Comparison (AWA Optimization)", fontsize=16, y=0.98)
872+
plt.suptitle(
873+
"3D Pareto Front Quality Comparison (AWA Optimization)", fontsize=16, y=0.98
874+
)
873875
plt.tight_layout(rect=[0, 0.03, 1, 0.95])
874876

875877
if save_path:
876878
if save_path.endswith(".gif"):
879+
877880
def update(frame):
878881
ax1.view_init(elev=25, azim=frame)
879882
ax2.view_init(elev=25, azim=frame)
880-
return fig,
883+
return (fig,)
881884

882885
from matplotlib.animation import FuncAnimation
883-
ani = FuncAnimation(fig, update, frames=np.arange(0, 360, 5), interval=100)
884-
ani.save(save_path, writer="pillow", dpi=100)
886+
887+
ani = FuncAnimation(fig, update, frames=np.arange(0, 360, 2), interval=40)
888+
ani.save(save_path, writer="pillow", fps=25, dpi=100)
885889
else:
886890
plt.savefig(save_path, dpi=150, bbox_inches="tight")
887891
plt.close()

0 commit comments

Comments
 (0)