Thanks Luke!  

I appreciate the suggestions.  Looks like there are plenty of options to 
solve my problem, even if the individual tick color doesn't change.

I put in a PR for the bugfix [1], so we can discuss the best way to go 
forward on that thread.  Thanks for this toolkit, it's helped me out a ton.

Chris

[1] #519: https://github.com/pyqtgraph/pyqtgraph/pull/519

On Thursday, July 27, 2017 at 6:02:23 PM UTC-4, Christopher Mullins wrote:
>
> Hi all,
>
> (1) Question is what it sounds like.  The situation is that I'm 
> prototyping an EEG analysis application, and I'm trying to simulate the 
> "Select bad channels" functionality in EEGLAB (a MATLAB GUI for this).  
> This involves plotting sixty-something data channels together separated 
> vertically, labeling the y-ticks with the name of each channel.  When a 
> user clicks a channel's data, the color should change (see minimal working 
> example below).
>
> The trouble is it's easy to see that a certain channel of data is bad, but 
> sometimes difficult to tell exactly which channel that is ie. the name of 
> the channel. So I'd like to change the color of the tick label as well.  Is 
> there a way to specify just _one_ particular tick and change its color?
>
> Happy for any further suggestions on the code.  Run it by pasting it into 
> a file and running python -i filename.py.
>
> (2) If you look at the comment I've made in my code, I realized that in 
> order for the sigClicked signal to fire, you need to use a PlotCurveItem 
> (as in the MouseSelection.py example).  If you use a PlotDataItem (which is 
> returned from PlotItem.plot() [1]) the function connected to the sigClicked 
> signal won't fire.  Is this expected behavior, or a bug?  
>
> Thanks,
> Chris
>
> import pyqtgraph as pq
> import numpy as np
> win = pq.GraphicsWindow(title="Basic EEG example")
> eegplot = win.addPlot(title="Multiple curves")
>
> # Set up the data sort of like I'll be interacting with it in my 
> application
> channel_names = ['Chan1', 'Chan2', 'Chan3']
> channel_data = [np.sin(np.linspace(0, 20, 1000)), np.sin(np.linspace(1, 21
> , 1000)), np.sin(np.linspace(2, 22, 1000))]
> chan_name_to_data = dict(zip(channel_names, channel_data))
> chan_name_to_curve = dict()
>
> def changeChannelColor(curve):
>     print("Firing changeChannelColor...")
>     curve.setPen('r')
>
> ticklabels = []
> for index, channel_name in enumerate(channel_names):
>     data = chan_name_to_data[channel_name]
>     data -= np.mean(data, axis=0)
>     # separate the channels vertically
>     offset = index*10
>     data += offset
>     ticklabels.append((offset, channel_name))
>     datacurve = pq.PlotCurveItem(y=chan_name_to_data[channel_name], pen=
> 'b', clickable=True)
>     # If you use a PlotDataItem instead, sigClicked does not fire.
>     #datacurve = pq.PlotDataItem(y=chan_name_to_data[channel_name], 
> pen='b', clickable=True)
>     chan_name_to_curve[channel_name] = datacurve
>     eegplot.addItem(datacurve)
> eegplot.getAxis('left').setTicks([ticklabels])
> eegplot.setLabel('bottom', 'Time', units='sec')
>
> # connect the signals correctly
> for channel_name, curve in chan_name_to_curve.items():
>     curve.sigClicked.connect(changeChannelColor)
>
>
>
> [1] 
> http://www.pyqtgraph.org/documentation/graphicsItems/plotitem.html#pyqtgraph.PlotItem.plot
>
>
>

-- 
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/cc2063de-540a-4dc8-b6c3-6bba99f4e592%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to