Skip to content
Snippets Groups Projects
Commit 71599410 authored by Nelly Barret's avatar Nelly Barret
Browse files

[M] generating figure with 12 subplots

parent c3c3f76e
No related branches found
No related tags found
No related merge requests found
......@@ -13,22 +13,30 @@ class Chart(Method):
self.dataset = dataset
self.trendline = None
def compute_trendline(self): # TODO: check order of selected indicators
def compute_trendline(self): # TODO: check order of selected indicators
print("compute trendline")
# for indicator in self.dataset.selected_indicators:
for index, row in self.dataset.data.head(7).iterrows():
fig, axs = plt.subplots(6, 2, figsize=(15, 15)) # rows, columns
i, j, k = 0, 0, 1 # i and j are indices to plot sub-figures and k is the counter to place figures
for index, row in self.dataset.data.head(12).iterrows():
data = []
for indicator in self.dataset.selected_indicators:
print(index, "-", row[indicator])
data.append(row[indicator])
max_value = self.dataset.data.head(11)[self.dataset.selected_indicators].values.max()
print(max_value)
max_value = self.dataset.data.head(12)[self.dataset.selected_indicators].values.max()
x = np.arange(0, len(data))
y = data
f = interp1d(x, y)
plt.ylim([0, max_value])
plt.xticks(np.arange(0, len(data)), self.dataset.selected_indicators, rotation=90)
plt.yticks(np.arange(0, max_value, step=max_value/5))
plt.plot(x, data, 'o', x, f(x), '-')
plt.title(str(row['CODE']) + " - " + self.dataset.env)
plt.show()
axs[i, j].axis(ymin=0, ymax=max_value)
axs[i, j].set_xticks(np.arange(0, len(data)))
axs[i, j].set_xticks(np.arange(0, max_value, step=max_value / 5))
axs[i, j].plot(x, data, 'o', x, f(x), '-')
title = str(row['CODE']) + " - " + str(self.dataset.env)
axs[i, j].set_title(title)
if k < 2:
k += 1
j += 1
else:
k = 1
i += 1
j = 0
fig.show()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment