Question

I am writing a program that imports data files and plots the data. Plots are added and removed by the user using buttons in a traits-based ui. I have all of this working, but I would like to add a tool that allows the user to select a line on the plot to perform actions on it (change color, remove, etc.). The only examples I can find are for selecting individual points on a scatter plot.

Sometimes plots overlap one another very closely, so my envisioned solution would be that on mouseover, the lineplot would highlight in some way (line width expands for that data set). If the user clicks the line, I need to get some feedback as to which plot was selected (name or index of plot for example) so I can allow actions to be performed on the selection. Here is the part of my code where I generate the plot:

#-------------------------------
# Generate chaco plot from list of data
def generatePlot(self):
    #Turn data list into arrayplotdata
    plotdata = ArrayPlotData()
    for i in range(len(self.dataList)):
        plotdata.set_data('x' + str(i), self.dataList[i][0])
        plotdata.set_data('y' + str(i), self.dataList[i][1])
    #Add plots of each arrayplotdata set
    dataPlot = Plot(plotdata)
    for i in range(len(self.dataList)):
        renderer = dataPlot.plot(('x' + str(i), 'y' + str(i)), color=getColor(i),   line_width=2, name=self.labelList[i])[0]
    #Format Plot  
    dataPlot.value_scale = 'log'
    dataPlot.title = 'IV Curve Comparison'
    dataPlot.x_axis.title = 'Bias (V)'
    dataPlot.y_axis.title = 'Current (A/cm' + u"\u00B2" + ')'
    dataPlot.y_axis.tick_label_formatter = lambda val: floatToString(val)
    dataPlot.padding_left = 100
    #Legend
    dataPlot.legend.visible = True
    dataPlot.legend.align = 'lr'
    dataPlot.legend.labels = self.labelList
    dataPlot.legend.tools.append(LegendTool(dataPlot.legend, drag_button='left'))

    self.dataPlot = dataPlot

Here is an image of the interface at this point with imported data plotted to give you an idea what i'm trying to do: http://i.stack.imgur.com/einry.png

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top