I guess this problem have already been discussed here, but I cannot find it.
I'm trying to add custom *AxisItem* in pyqtgraph to existing *PlotWidget* that 
was generated by Qt Designer. There is related topic here 
<http://stackoverflow.com/questions/18373714/can-i-replace-an-axisitem-on-a-qt-creator-promoted-pyqtgraph-widget>,
 
but there is no exact answer with code example and I cannot comment there, 
so I've created a new topic again.

This is my custom *AxisItem* (based on this 
<https://gist.github.com/friendzis/4e98ebe2cf29c0c2c232/> code):  
import pyqtgraph as pg
import datetime

def int2td(ts):
    return(datetime.timedelta(seconds=float(ts)/1e6))

class TimeAxisItem(pg.AxisItem):
    def __init__(self, *args, **kwargs):
        super(TimeAxisItem, self).__init__(*args, **kwargs)
    def tickStrings(self, values, scale, spacing):
        return [int2dt(value).strftime("%H:%M:%S") for value in values]

This is my main *QtPlotter* class:
from pyqtgraph.Qt import QtGui
from template_pyqt import Ui_Form # Ui_Form is generated by Qt Designer

class QtPlotter:
    def __init__(self):
        self.app = QtGui.QApplication([])
        self.win = QtGui.QWidget()
        self.ui = Ui_Form()
        self.ui.setupUi(self.win)
        self.win.show()

        self.ui_plot = self.ui.plot 
        self.ui_plot.showGrid(x=True, y=True)

And then I'm trying to add my custom *AxisItem*:
        self.ui_plot.getPlotItem().axes['bottom']['item'] = TimeAxisItem(
orientation='bottom')

I have no errors, but this does not give any effect. 
Same question on Stack Overflow here 
<http://stackoverflow.com/questions/42886849/how-to-add-custom-axisitem-to-existing-plotwidget>
.

-- 
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/cdb3fb57-99ec-4b18-8365-4647e6a76289%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to