-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
32 lines (25 loc) · 886 Bytes
/
Copy pathplot.py
File metadata and controls
32 lines (25 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df = pd.read_csv("results.csv")
labels = df["label"].unique()
colors = {"INBRED": "red", "OUTBRED": "blue", "MIXED": "green"}
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(10, 8))
for label in labels:
grp = df[df["label"] == label].sort_values("gen")
x = grp["gen"].to_numpy()
ax1.plot(x, grp["avgfitness"].to_numpy(), label=label, color=colors[label], linewidth=2)
ax2.plot(x, grp["fixedloci"].to_numpy(), label=label, color=colors[label], linewidth=2)
ax1.set_title("Avg Fitness Over Generations")
ax1.set_xlabel("Generation")
ax1.set_ylabel("Avg Fitness")
ax1.legend()
ax1.grid(True)
ax2.set_title("Fixed Deleterious Loci")
ax2.set_xlabel("Generation")
ax2.set_ylabel("Fixed Loci Count")
ax2.legend()
ax2.grid(True)
plt.tight_layout()
plt.savefig("inbreeding_plot.png", dpi=150)
plt.show()