forked from luodajie/dataanalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBarGraph_Plot.py
More file actions
50 lines (43 loc) · 1.74 KB
/
Copy pathBarGraph_Plot.py
File metadata and controls
50 lines (43 loc) · 1.74 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT
import matplotlib.pyplot as plt
from matplotlib import style
from PyQt4 import QtGui
style.use('ggplot')
class MatplotBarWidget(QtGui.QWidget):
def __init__(self, parent=None):
super(MatplotBarWidget, self).__init__(parent)
self.setWindowIcon(QtGui.QIcon("icon.png"))
self.setGeometry(180, 90, 1000, 620)
self.canvas = FigureCanvas(plt.figure())
self.canvas.setWindowOpacity(1)
self.canvas.setObjectName("bar-canvas")
self.canvas.resize(800, 620)
plt.xlabel("Result")
plt.ylabel("Count")
plt.grid(True)
plt.title("Categorical bar Graph \n Result v/s Count")
self.canvas.draw()
self.toolbar = NavigationToolbar2QT(self.canvas, self)
self.toolbar.setObjectName("bar-toolbar")
self.setStyleSheet("""
#bar-toolbar{
background-color: #cccccc;
}
""")
self.layoutVertical = QtGui.QVBoxLayout(self)
self.layoutVertical.addWidget(self.canvas)
self.layoutVertical.addWidget(self.toolbar)
def print_g2(self, f_alph=None):
plt.rcParams.update({'figure.max_open_warning': 0})
z = []
for i in range(len(f_alph)):
z.append(i)
plt.bar(z, f_alph.Count, color='#ff6666', align='center')
plt.xticks(z, f_alph.result, rotation='vertical')
plt.xlabel("Result")
plt.ylabel("Count")
plt.title("Categorical bar Graph \n Result v/s Count")
plt.grid(linestyle='-', linewidth='0.5', color='#333333')
plt.margins(0.01)
self.canvas.draw()