Plot Grid not shown

863 views
Skip to first unread message

Stefan H

unread,
Apr 28, 2014, 2:31:08 AM4/28/14
to pyqt...@googlegroups.com
Hello,

I have problems to get the Plot Grid shown for my custom layout PlotWidget.

So I have GraphicsLayoutWidget() which contains multiple ViewBoxes with linked AxisItems, every thing is shown correctly except the Grid. When I turn on the grid by calling setGrid on the AxisItem also the ticks on the axis disappear and no grid lines are shown.

Does anyone have a hint for me, why this is not working? 

Here is some simple example code:

import pyqtgraph as pg
from PyQt4 import QtGui
import numpy as np


def main():
   
import sys
    app
= QtGui.QApplication(sys.argv)


    plotLayout
= pg.GraphicsLayoutWidget()




    p1
= pg.ViewBox()
   
    line
= pg.PlotDataItem(y=np.random.random(400))
    p1
.addItem(line)


    plotLayout
.addItem(p1,0,0)


    xAxis
= pg.AxisItem('bottom')
    xAxis
.setZValue(-1000)
    xAxis
.setFlag(xAxis.ItemNegativeZStacksBehindParent)
    xAxis
.setGrid(1.0)
    xAxis
.linkToView(p1)
    plotLayout
.addItem(xAxis,1,0)


    plotLayout
.show()
    sys
.exit(app.exec_())


if __name__ == '__main__':
    main
()








Thank you,
Stefan

Luke Campagnola

unread,
Apr 28, 2014, 8:16:31 AM4/28/14
to pyqt...@googlegroups.com
On Mon, Apr 28, 2014 at 2:31 AM, Stefan H <stefan.ho...@gmail.com> wrote:
So I have GraphicsLayoutWidget() which contains multiple ViewBoxes with linked AxisItems, every thing is shown correctly except the Grid. When I turn on the grid by calling setGrid on the AxisItem also the ticks on the axis disappear and no grid lines are shown.

[snip] 
    xAxis.setGrid(1.0)

 The alpha value should be in the range (0-255); this line makes the grid lines mostly transparent. 
I'll update the documentation to clarify this.

Stefan H

unread,
Apr 28, 2014, 12:49:58 PM4/28/14
to pyqt...@googlegroups.com

Thank you, now the grid is shown correctly
Reply all
Reply to author
Forward
0 new messages