Hello. bar graph code with four diferent bars is attached here which by the
way works, but I don't like the way it is shown. Bars covers each other,
instead of this I would like to have one by one bar close together (four of
them for each day). X axis represent days in month.
In case you need more informations just let me know about.
Thanks in advance, Vlado
--
You received this message because you are subscribed to the Google Groups
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/c8313786-deb7-4266-8fcb-a050eac6d078n%40googlegroups.com.
def graph_cas_ogrevanja_zg_sp(): # mesecni - 31 dni
global OUT_Buffer_ogrevanje_spodaj, OUT_Buffer_ogrevanje_zgoraj
global OUT_Buffer_ogrevanje_bojler, OUT_Buffer_ogrevanje_drva
timelist = []
out_buffer_ogrevanje_zg = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
out_buffer_ogrevanje_sp = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
out_buffer_ogrevanje_bo = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
out_buffer_ogrevanje_dr = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
x = []
n = 31
i = 0
m = 0
H = pg.plot()
H.resize(1300, 500)
currentMonth = dt.datetime.now().strftime("%m")
m = int(currentMonth)
while i < n:
x.append(i)
i += 1
currentTime = dt.datetime.now().strftime("%d")
timelist.append(currentTime)
timelist = timelist[-n:]
for i in range(0, n):
timelist[i] = int(timelist[i])
i = n
j = 0
while i > 0:
if ((m == 12) or (m == 10) or (m == 8) or (m == 7) or (
m == 5) or (m == 2) or (m == 1)):
timelist[i - 1] = timelist[i - 1] - j
if timelist[i - 1] < 1:
timelist[i - 1] = timelist[i - 1] + 30
j += 1
i -= 1
if ((m == 11) or (m == 9) or (m == 6) or (m == 4)):
timelist[i - 1] = timelist[i - 1] - j
if timelist[i - 1] < 1:
timelist[i - 1] = timelist[i - 1] + 31
j += 1
i -= 1
if m == 3:
timelist[i - 1] = timelist[i - 1] - j
if timelist[i - 1] < 1:
timelist[i - 1] = timelist[i - 1] + 28
j += 1
i -= 1
for i in range(0, n):
timelist[i] = str(timelist[i])
for i in range(0, n):
out_buffer_ogrevanje_zg[i] = OUT_Buffer_ogrevanje_zgoraj[i]
out_buffer_ogrevanje_sp[i] = OUT_Buffer_ogrevanje_spodaj[i]
out_buffer_ogrevanje_bo[i] = OUT_Buffer_ogrevanje_bojler[i]
out_buffer_ogrevanje_dr[i] = OUT_Buffer_ogrevanje_drva[i]
Bufer_ogrevanje_zgoraj(0, out_buffer_ogrevanje_zg)
Bufer_ogrevanje_spodaj(0, out_buffer_ogrevanje_sp)
Bufer_ogrevanje_bojler(0, out_buffer_ogrevanje_bo)
Bufer_ogrevanje_drva(0, out_buffer_ogrevanje_dr)
bg1 = pg.BarGraphItem(x=x, height=out_buffer_ogrevanje_zg,
width=0.8, brush='r')
bg2 = pg.BarGraphItem(x=x, height=out_buffer_ogrevanje_sp,
width=0.6, brush='b')
bg3 = pg.BarGraphItem(x=x, height=out_buffer_ogrevanje_bo,
width=0.4, brush='g')
bg4 = pg.BarGraphItem(x=x, height=out_buffer_ogrevanje_dr,
width=0.2, brush='y')
H.addItem(bg1)
H.addItem(bg2)
H.addItem(bg3)
H.addItem(bg4)
H.setTitle('Cas ogrevanja Zgoraj (Rd), Spodaj (Mo), Bojler (Ze), Drva (Ru)')
H.showGrid(True, True)
H.setLabel('left', 'Cas', units='min', **{'font-size': '20pt'})
H.setLabel('bottom', 'Cas', units='dan', **{'font-size': '20pt'})
ticks = list(enumerate(timelist))
ticks = ticks[::4]
ax = H.getAxis("bottom")
ax.setTicks([ticks])