-
Notifications
You must be signed in to change notification settings - Fork 0
/
stacked_bar_chart.py
36 lines (28 loc) · 1.28 KB
/
stacked_bar_chart.py
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
33
34
35
36
"""
File Summary: Draw a stacked bar chart to display results between Leela Zero and other engines.
"""
import matplotlib.pyplot as plt
import read_pgn_files
def drawStackedBarChart(labels, data1, data2, title, xLabel, yLabel):
fig, ax = plt.subplots()
ax.bar(labels, data1, label='Leela Zero Points')
ax.bar(labels, data2, bottom=data1, label='Other Engine Points')
ax.legend()
ax.set_title(title)
ax.set_xlabel(xLabel)
ax.set_ylabel(yLabel)
plt.savefig(title + '.png')
plt.show()
class StackedBarChartPlotter:
def __init__(self):
self.df = read_pgn_files.readAllPgnFilesIntoDf(saveFile=False)
def drawWhitePlot(self):
drawStackedBarChart(self.df.index, self.df['Leela White Points'], self.df['Leela White Missed Points'], 'Leela Zero (White) Against Other Engines',
'Other Chess Engine & Color', 'Points')
def drawBlackPlot(self):
drawStackedBarChart(self.df.index, self.df['Leela Black Points'], self.df['Leela Black Missed Points'], 'Leela Zero (Black) Against Other Engines',
'Other Chess Engine & Color', 'Points')
if __name__ == '__main__':
plotter = StackedBarChartPlotter()
plotter.drawWhitePlot()
plotter.drawBlackPlot()