Thank you very much for the help. Have a nice day (hoping for you is morning as for me)
Thank you in advance for your time. Best regards, Andrea Gotelli. ________________________________ From: [email protected] <[email protected]> on behalf of Kenneth Lyons <[email protected]> Sent: Saturday, June 20, 2020 9:04:38 AM To: pyqtgraph <[email protected]> Subject: Re: [pyqtgraph] Re: Plotting elements of a class Yes, the symbolSize and symbolBrush arguments accept lists, for example: red = pg.mkBrush('r') blue = pg.mkBrush('b') brushes = [blue if m.accept else red for m in measurements] sizes = [10 if m.accept else 5 for m in measurements] p1.plot(xlist, ylist, pen=None, symbolSize=sizes, symbolBrush=brushes) On Friday, June 19, 2020 at 11:40:52 PM UTC-7, andrea gotelli wrote: Thank you very much for the reply. I have tried the second method yesterday, but for creating a lots of plots, I also experienced lag.. Now I have another question that should be the final. Now plotting all these points, I would like to have two groups, one group with normal blue points, and a second group with small red points. The selection is based on the Boolean in the processedMeasurements. For example: for measurement in processedMeasurements:, if measurement.accepted == True: # Then put in group one... Is there a way to pass the color and the symbol size as array?? Thank you in advance for your time. Best regards, Andrea Gotelli. ________________________________ From: [email protected] <[email protected]> on behalf of Kenneth Lyons <[email protected]> Sent: Saturday, June 20, 2020 7:32:28 AM To: pyqtgraph <[email protected]> Subject: [pyqtgraph] Re: Plotting elements of a class The plot method expects multiple points in lists or arrays, and you're passing scalars for the x and y arguments. One thing you could do is extract the coordinates from all measurements into lists and pass them to plot. For example: xlist = [m.x for m in processedMeasurements] ylist = [m.y for m in processedMeasurements] p1.plot(xlist, ylist, pen=None, symbol='o') Is there a way to rewrite the exception message that could make it more clear? By the way, you can plot a single point at a time by wrapping the coordinate values in lists, e.g. plot([0.], [1.]), but this approach won't scale well as each plot call generates a separate PlotDataItem. On Friday, June 19, 2020 at 10:43:55 AM UTC-7, andrea gotelli wrote: Hi, I have this problem where i need to plot elements that are stored into an list containing a UDT. the class is the following: class Measurement: def __init__(self, time, mh_dist, color, x, y): self.time = float(time) self.mh_dist = float(mh_dist) self.color = color self.x = float( x ) self.y = float( y ) The I create a list containing elements of this class. processedMeasurements = [] for topic, meas, t in bag.read_messages(topics=['/Measurements']): if meas.accepted: processedMeasurements.append( Measurement( t.to_sec(), meas.distance, 'b', meas.pose.position.x, meas.pose.position.y) ) else: processedMeasurements.append( Measurement( t.to_sec(), meas.distance, 'r', meas.pose.position.x, meas.pose.position.y) ) The only thing that is important to understan here is that I am saving data readed from a file. Later I would like to plot this data. For example, the measurements contains a x and y position. I would like to plot this position for every element in the list processedMeasurements. However, doing something like: for measurement in processedMeasurements: p1.plot(measurement.x, measurement.y, pen=None, symbol='o') Gives me the following error: Traceback (most recent call last): File "/home/agotelli/catkin_ws/src/Project1/plotting/scripts/plotting", line 514, in <module> p1.plot(measurement.x, measurement.y, pen=None, symbol='o') File "/usr/local/lib/python2.7/dist-packages/pyqtgraph/graphicsItems/PlotItem/PlotItem.py", line 640, in plot item = PlotDataItem(*args, **kargs) File "/usr/local/lib/python2.7/dist-packages/pyqtgraph/graphicsItems/PlotDataItem.py", line 185, in __init__ self.setData(*args, **kargs) File "/usr/local/lib/python2.7/dist-packages/pyqtgraph/graphicsItems/PlotDataItem.py", line 395, in setData raise Exception('When passing two unnamed arguments, both must be a list or array of values. (got %s, %s)' % (str(type(args[0])), str(type(args[1])))) Exception: When passing two unnamed arguments, both must be a list or array of values. (got <type 'float'>, <type 'float'>) Does anybody knows how to solve this problem?? Thank you in advance. -- 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/db3cf471-8c19-431c-8fe9-6e85bb907c8fo%40googlegroups.com<https://groups.google.com/d/msgid/pyqtgraph/db3cf471-8c19-431c-8fe9-6e85bb907c8fo%40googlegroups.com?utm_medium=email&utm_source=footer>. -- 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]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/7d8b055e-098a-4de7-82d8-efd9fddaef2co%40googlegroups.com<https://groups.google.com/d/msgid/pyqtgraph/7d8b055e-098a-4de7-82d8-efd9fddaef2co%40googlegroups.com?utm_medium=email&utm_source=footer>. -- 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/PR3P189MB104999FAB09913639326C687A1990%40PR3P189MB1049.EURP189.PROD.OUTLOOK.COM.
