Skip to content
This repository was archived by the owner on Jan 8, 2023. It is now read-only.

Commit b349abf

Browse files
authored
Stop weekday plot being sorted alphabetically
Add lines 104/106 & edit line 105 to first plot each weekday as a number and then overwrite with the actual day. Prevents the weekdays being sorted alphabetically due to this bug in Matplotlib < 2.2.0: matplotlib/matplotlib#9312
1 parent 52b741d commit b349abf

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎server/create_plots.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ def set_title(plt, text):
101101
fig, ax = plt.subplots()
102102
fig.set_size_inches(SIZE)
103103
weekdays_title = ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag']
104-
ax.bar(weekdays_title, weekdays/sum(weekdays)*100, color=COLOR)
104+
weekdays_index = range(len(weekdays_title))
105+
ax.bar(weekdays_index, weekdays/sum(weekdays)*100, color=COLOR)
106+
plt.xticks(weekdays_index, weekdays_title)
105107
fig.autofmt_xdate()
106108
plt.ylabel('relativer Konsum [%]')
107109
set_title(plt, 'Durchschnittlicher Konsum nach Wochentag')
@@ -149,4 +151,4 @@ def set_title(plt, text):
149151
plt.ylabel('Gesamtkonsum')
150152
set_title(plt, 'Wöchentlicher Konsum in '+str(YEAR))
151153
plt.savefig(img_path+'/year_'+str(YEAR)+'.svg', transparent=True)
152-
plt.close()
154+
plt.close()

0 commit comments

Comments
 (0)