MCPcopy Create free account
hub / github.com/COLA-Laboratory/TransOPT / save_individual_frames

Function save_individual_frames

demo/comparison/analysis_plot.py:233–261  ·  view source on GitHub ↗

Save each frame of the three objectives as a separate plot for a given workload, algorithm, and seed.

(workload, algorithm, seed)

Source from the content-addressed store, hash-verified

231
232
233def save_individual_frames(workload, algorithm, seed):
234 """
235 Save each frame of the three objectives as a separate plot for a given workload, algorithm, and seed.
236 """
237 # Load data for the specific seed
238 df = load_data(workload, algorithm, seed)
239
240 # Ensure the directory for saving frames exists
241 frames_dir = package_path / "demo" / "comparison" / "frames" / f"{algorithm}_{workload}_{seed}"
242 os.makedirs(frames_dir, exist_ok=True)
243
244 for idx in range(len(df)):
245 fig = plt.figure()
246 ax = fig.add_subplot(111, projection='3d')
247
248 # Add data points from the DataFrame row by row
249 x, y, z = df.iloc[idx][objectives[0]], df.iloc[idx][objectives[1]], df.iloc[idx][objectives[2]]
250
251 # Plot and customize as needed
252 ax.scatter(x, y, z, color='r')
253 ax.set_title(f"Frame {idx} for {workload} - {algorithm} - Seed {seed}")
254 ax.set_xlabel(objectives[0])
255 ax.set_ylabel(objectives[1])
256 ax.set_zlabel(objectives[2])
257
258 # Save the plot as a file
259 frame_file = frames_dir / f"frame_{idx:04d}.png"
260 plt.savefig(frame_file)
261 plt.close(fig) # Close the plot to free memory
262
263
264def load_workloads():

Callers

nothing calls this directly

Calls 2

closeMethod · 0.80
load_dataFunction · 0.70

Tested by

no test coverage detected