Skip to content

Instantly share code, notes, and snippets.

@m4r1vs
Created January 23, 2024 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m4r1vs/015746d4a957538c52dd52dc06c56af9 to your computer and use it in GitHub Desktop.
Save m4r1vs/015746d4a957538c52dd52dc06c56af9 to your computer and use it in GitHub Desktop.
import os
import matplotlib.pyplot as plt
import pandas as pd
cwd = os.getcwd()
def plot_file(file_path, filename):
print(f'Processing file: {file_path}')
with open(file_path, 'r') as file:
lines = file.readlines()
lines[0] = lines[0].lstrip('# ')
with open(file_path, 'w') as file:
file.writelines(lines)
df = pd.read_csv(file_path, delimiter=' ')
plt.figure(figsize=(10, 10))
plt.subplots_adjust(bottom=0.4)
labels = []
for index, row in df.iterrows():
labels.append("NP=" + str(row['NPROCS']) + ", NN=" + str(row['NNODES']) + "I=" + str(row['ILINES']))
bars = plt.bar(labels, df['TIME'], color='maroon', width=0.4)
plt.xticks(rotation=45, ha='right')
plt.xlabel('Fälle')
plt.ylabel('Zeit')
plt.title(filename)
for bar in bars:
yval = bar.get_height()
plt.text(bar.get_x() + bar.get_width() / 2, yval + 0.1, round(yval, 1), ha='center', va='bottom')
plt.savefig(filename.rstrip(".dat") + ".png", dpi=200, bbox_inches='tight')
for filename in os.listdir(cwd):
if not filename.endswith(".dat"):
continue
file_path = os.path.join(cwd, filename)
plot_file(file_path, filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment