Hanging xaxis whe trying to supply custom AxisItem to PlotWidget in PyQt4

155 views
Skip to first unread message

Kenneth Nielsen

unread,
Jun 16, 2016, 4:11:05 AM6/16/16
to pyqtgraph

Hallo pyqtgraph developers and thanks for an awesome package

I want to embed a pyqtgraph Qt Widget into my own Qt program and I want to use a custom xaxis (with time formatting, but that is besides the point). When I try to do it by supplying the axisItem argument to PlotWidget I do get the new axis in place, but I also still have the old x-axis hanging at the top left of the widget. The following is the smallest code example that I can use to reproduce the proble

import sys

import numpy as np
from pyqtgraph import PlotWidget, AxisItem
from PyQt4 import QtGui, QtCore


class TimeAxisItem(AxisItem):
   
"""Only included to show that the point is to subclass"""


class Example(QtGui.QWidget):
   
def __init__(self):
       
super(Example, self).__init__()        
       
self.setGeometry(300, 300, 1000, 1000)
       
self.plot = PlotWidget(self, axisItems={'bottom': TimeAxisItem(orientation='bottom')})
       
self.plot.resize(900, 900)
       
self.curve = self.plot.plot(np.linspace(0, 10, 100), np.random.random(100))
       
self.show()


if __name__ == '__main__':
    app
= QtGui.QApplication(sys.argv)
    ex
= Example()
    sys
.exit(app.exec_())

Which produces the Window shown in the attached image.

Am I doing it wrong? I should say, that I can produce the correct result (dateformatting of xaxis without the hanging axis) by simply getting the existing xaxis and monkey patching tickStrings, but I would rather not have to do that.

Regards Kenneth

Kenneth Nielsen

unread,
Jul 14, 2016, 2:06:20 AM7/14/16
to pyqtgraph
No one has any input on this?

vas...@gmail.com

unread,
Jul 14, 2016, 4:06:33 AM7/14/16
to pyqt...@googlegroups.com
Search the group before asking, this is "I-don't-know-what" time that I suggesting updating pyqtgraph:
http://stackoverflow.com/questions/33717000/pyqtgraph-custom-tick-labels-potential-bug

--
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 pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/9103f480-1265-423f-9568-f480e7e9c6cd%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Kenneth Nielsen

unread,
Jul 14, 2016, 10:16:43 AM7/14/16
to pyqtgraph
Sorry about that.

I did search for it (which I always do before reporting bugs), but did not find that stackoverflow thread.

Thanks for the reply.
Reply all
Reply to author
Forward
0 new messages