Untitled
unknown
plain_text
a year ago
946 B
17
Indexable
import matplotlib.pyplot as plt
# Define energy and temperature values for the graph
energy = [0, 20, 40, 60, 80, 100] # Arbitrary energy values
temperature_heating = [-50, -10, -10, 30, 60, 90] # Below melting, melting, liquid heating
temperature_cooling = [90, 60, 30, -10, -10, -50] # Reverse for cooling
# Create the heating graph
plt.figure(figsize=(8, 6))
plt.plot(energy, temperature_heating, label="Heating", marker='o', linestyle='-', linewidth=2)
plt.plot(energy, temperature_cooling, label="Cooling", marker='x', linestyle='--', linewidth=2)
# Add labels and title
plt.title("Heating and Cooling Graph of the Substance")
plt.xlabel("Energy (arbitrary units)")
plt.ylabel("Temperature (°C)")
plt.axhline(0, color='gray', linestyle=':', linewidth=1) # Highlight 0°C for melting point
plt.axvline(40, color='gray', linestyle=':', linewidth=1) # Flat segment for phase change
plt.legend()
plt.grid()
# Show the graph
plt.show()
Editor is loading...
Leave a Comment