Added some imports into code ...
sobota, 12. december 2020 ob 10:35:22 UTC+1 je oseba Vlado Kršlin napisala:

>
> Hello,  I put together few lines of code for showing temperature graph. 
> Everything works ok except xaxis is shown with all 46 numbers which 
> represent minuttes from now back. Is there any way to reduce shown nubers, 
> for example to show every tenth number?
> Small piece of  graph code is attached here to show issue.
>
> With best regards, 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/27efbc6d-2a2c-4548-962e-43c217fe9e83n%40googlegroups.com.
import time
import sys
import pyqtgraph as pg
from PyQt4 import QtGui
import numpy
from pyqtgraph import AxisItem
from datetime import datetime, timedelta
from time import mktime
import datetime as dt

pg.setConfigOptions(antialias=True)
pg.setConfigOption('background', '#c7c7c7')
pg.setConfigOption('foreground', '#000000')


OUT_Buffer_Pec_drva = [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,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # 46



def graph_pec_drva(): 
    global OUT_Buffer_Pec_drva
    timelist = []
    x = []
    n = 46
    i = 0

    H = pg.plot()
    H.resize(1200, 500)

    while i < n:
        x.append(i)
        i += 1
        currentTime = dt.datetime.now().strftime("%M")
        timelist.append(currentTime)
        timelist = timelist[-n:]
    for i in range(0, n):
        timelist[i] = int(timelist[i])
    i = n
    j = 0
    while i > 0:
        timelist[i - 1] = timelist[i - 1] - j
        if timelist[i - 1] < 0:
            timelist[i - 1] = timelist[i - 1] + 60
        j += 1
        i -= 1
    for i in range(0, n):
        timelist[i] = str(timelist[i])

    H.setTitle('Temperatura Pec na drva')
    H.plot(x, OUT_Buffer_Pec_drva, pen=pg.mkPen(
        color='#ff0000', width=3))
    H.showGrid(True, True)
    H.setLabel('left', 'Temperatura', units='deg C', **{'font-size': '20pt'})
    H.setLabel('bottom', 'Cas', units='min', **{'font-size': '20pt'})
    
    ticks = list(enumerate(timelist))
    ax = H.getAxis("bottom")
    ax.setTicks([ticks])
    

Reply via email to