-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
27 lines (21 loc) · 924 Bytes
/
plot.py
File metadata and controls
27 lines (21 loc) · 924 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
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
class Plotter:
def __init__(self):
self.figure = Figure()
self.canvas = FigureCanvas(self.figure)
def get_canvas(self):
return self.canvas
def plot_comparison(self, steel_costs, concrete_costs, labels):
ax = self.figure.add_subplot(111)
ax.clear()
bar_width = 0.35
x = range(len(labels))
ax.bar(x, steel_costs, width=bar_width, label="Steel", color="blue")
ax.bar([p + bar_width for p in x], concrete_costs, width=bar_width, label="Concrete", color="orange")
ax.set_xticks([p + bar_width / 2 for p in x])
ax.set_xticklabels(labels, rotation=45, ha="right")
ax.set_title("Cost Comparison: Steel vs. Concrete")
ax.set_ylabel("Cost (₹)")
ax.legend()
self.canvas.draw()