Skip to content
Snippets Groups Projects
Commit 7f55b3e4 authored by Aymeric berthoumieu's avatar Aymeric berthoumieu
Browse files

python script for plot

parent b871e110
No related branches found
No related tags found
1 merge request!22Aymeric
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
stats = pd.read_csv("report.csv")
columns = stats.columns
print(columns)
behaviour_stack = []
behaviour_headers = []
AccessoriesAndCaptors_stack = []
AccessoriesAndCaptors_headers = []
for c in columns:
if c[:2] == "b_":
behaviour_headers.append(c)
behaviour_stack.append(stats[c].values.tolist())
elif (c[:2] == "a_") or (c[:2] == "c_"):
AccessoriesAndCaptors_headers.append(c)
AccessoriesAndCaptors_stack.append(stats[c].values.tolist())
behaviour_stack = np.vstack(behaviour_stack)
# AccessoriesAndCaptors_stack = np.vstack(AccessoriesAndCaptors_stack)
# First plot
fig, ax = plt.subplots(1, 1, figsize=(45, 50))
ax = plt.gca()
ax.stackplot(range(1, len(stats) + 1), behaviour_stack, labels=behaviour_headers, alpha=0.7)
ax.set_title("Evolution of population with behaviour distinction.", fontsize=18)
ax.legend(fontsize=10, ncol=4)
plt.xlabel("Number of steps.")
plt.ylabel("Number of Animals.")
# Second plot
fig, ax = plt.subplots(1, 1, figsize=(45, 50))
ax = plt.gca()
ax.stackplot(range(1, len(stats) + 1), behaviour_stack, labels=behaviour_headers, alpha=0.7)
ax.set_title("Evolution of accessories and captors population.", fontsize=18)
ax.legend(fontsize=10, ncol=4)
plt.xlabel("Number of steps.")
plt.ylabel("Number of accessories and captors.")
plt.show()
......@@ -85,16 +85,18 @@ std::vector<Animal *> Environment::detectedNeighbors(Animal* a){
void Environment::die() {
// kill animal in the ecosystem at the end of the step
cout << "size = " << animals.size() << endl;
// first we update Statistics
for (std::vector<Animal*>::iterator iter = animals.begin(); iter != animals.end(); ++iter) {
// All animal at the end of the vector at this step are going to die
// Behaviours
if ((*iter)->getLife() <= 0){
if ((*iter)->getIsMultiple()) {
cout << " decrement multiple " << endl;
statistics.modifyData(multiple, false);
} else {
std::string behaviour = (*iter)->getBehaviourName();
cout << " decrement " << behaviour << endl;
statistics.modifyData(behaviour, false);
}
// Captors and accessories
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment