Note
Go to the end to download the full example code.
Histogram ReaderΒΆ
Process histogram data from fix ave/hist
commands.

/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/pylimer_tools/io/read_lammps_output_file.py:224: FutureWarning: errors='ignore' is deprecated and will raise in a future version. Use to_numeric without passing `errors` and catch exceptions explicitly instead
df = df.apply(pd.to_numeric, errors="ignore")
import os
import matplotlib.pyplot as plt
from pylimer_tools.io.read_lammps_output_file import read_histogram_file
file_path = os.path.join(
os.getcwd(),
"../..",
"tests/pylimer_tools/fixtures/example_vec_avg_file.out.vec-avg.txt",
)
# Read histogram data
histogram_data = read_histogram_file(file_path)
# Plot histogram for specific timestep
final_timestep = histogram_data["TimeStep"].max()
final_hist = histogram_data[histogram_data["TimeStep"] == final_timestep]
plt.bar(final_hist["value1"], final_hist["value2"])
plt.xlabel("Density")
plt.ylabel("Frequency")
plt.title(f"Density Distribution at Step {final_timestep}")
plt.show()
Total running time of the script: (0 minutes 0.061 seconds)