LinePlotItem disappears when I add a ScatterPlot Item

53 views
Skip to first unread message

Evangelos Petsalis

unread,
Jul 15, 2019, 8:06:48 PM7/15/19
to pyqtgraph
Hi,

I am new to using PyQTGraph but I encountered a very weird issue. 
Every time I add a ScatterPlotItem, while there is n existing LinePlotItem, the LinePlotItem disappears. 
Here is the sample code that I run. 

I am sure I am missing something very simple, but any help would greatly be appreciated. 

Thanks in advance for the help.




import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph as pg
import pyqtgraph.opengl as gl
import pyqtgraph.examples as ex
import numpy as np
import sys

app = QtGui.QApplication([])
w = gl.GLViewWidget()
w.setWindowTitle('pyqtgraph example: GLSurfacePlot')

## Add a grid to the view
g = gl.GLGridItem()
w.addItem(g)

## Add Axis
a = gl.GLAxisItem()
w.addItem(a)

# add a line
el2 = gl.GLLinePlotItem(pos=np.array([[0, 0, 1], [1, 1, 1]]), color=[1, 0.0, 1., 1.], width=10)
w.addItem(el2)

# add scatter plots
el1 = gl.GLScatterPlotItem(pos=np.array([[0, 0, 1], [1, 1, 1]]), color=[1, 0.0, 1., 1.], size=10)
w.addItem(el1)

w.show()

vas...@gmail.com

unread,
Jul 15, 2019, 8:25:31 PM7/15/19
to pyqt...@googlegroups.com
Hi.

You are probably missing that your line and scatter plot coordinates overlaps and to they have the same color parameters. Try to change those parameters as:

import numpy as np

import pyqtgraph as pg
import pyqtgraph.opengl as gl
import numpy as np

v = pg.Qt.QtGui.QApplication([])

w = gl.GLViewWidget()
w.setWindowTitle('pyqtgraph example: GLSurfacePlot')

## Add a grid to the view
g = gl.GLGridItem()
w.addItem(g)

## Add Axis
a = gl.GLAxisItem()
w.addItem(a)

# add a line
el2 = gl.GLLinePlotItem(pos=np.array([[0, 1, 0], [1, 1, 1], [1.5, 1.3, 1.2]]), color=[1, 1., 1., 1.], width=10)

w.addItem(el2)

# add scatter plots
el1 = gl.GLScatterPlotItem(pos=np.array([[0, 0, 1], [2, 2, 2],[3, 2, 3], [3, 3, 4]]), color=[1, 0.0, 1., 1.], size=10)
w.addItem(el1)

w.show()

while w.isVisible():
    v.processEvents();


--
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/d6c54eb5-8188-4267-8449-d17c6dd9e7ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Evangelos Petsalis

unread,
Jul 16, 2019, 11:34:43 AM7/16/19
to pyqtgraph
Hi and thanks for the prompt response. 

Unfortunately, this does not seem to be the problem. Actually, the behavior I see is a bit weird. 
When I execute the command to add the line, I can see the line on the app. Then I add the scattered plots.; both lines and scattered points show properly until I move the mouse on the app window ... the moment I click on that window all the lines disappear (including grid lines if present). 

I assume the code that you posted works properly on your machine. Which python version are you using? 

Thanks again


To unsubscribe from this group and stop receiving emails from it, send an email to pyqt...@googlegroups.com.

Evangelos Petsalis

unread,
Jul 16, 2019, 2:17:36 PM7/16/19
to pyqtgraph
Problem went away on Python 3.7
Reply all
Reply to author
Forward
0 new messages