Demo091224 / visualization.py
SuriRaja's picture
Update visualization.py
ddc918b verified
raw
history blame contribute delete
996 Bytes
import matplotlib.pyplot as plt
def visualize_results(simulator, length, width, thickness, stress, deformation):
"""
Generates 2D visualizations for simulation results.
Parameters:
simulator (str): Name of the simulator (e.g., 'Python-Based Solver').
length (float): Length of the object.
width (float): Width of the object.
thickness (float): Thickness of the object.
stress (float): Stress value.
deformation (float): Deformation value.
Returns:
str: Path to the 2D visualization image.
"""
# Generate 2D bar chart
fig, ax = plt.subplots(figsize=(6, 4))
ax.bar(["Stress", "Deformation"], [stress, deformation], color=["red", "blue"])
ax.set_title(f"Simulation Results ({simulator})")
ax.set_ylabel("Magnitude")
ax.grid(True, linestyle="--", alpha=0.6)
# Save the chart
output_path = "results_2d.png"
plt.savefig(output_path)
plt.close(fig)
return output_path, None