I cannot figure out how to use the "names" in matplotlib when plotting data returned by numpy.genfromtxt command. Scenario: 1. I have a file with columns headers and rows of values 2. I don't know the column headers beforehand--they are generated programmatically and may change during the program run 3. I need to read the data AND the column headers, plot them and produce a corresponding legend.
I can read the data columns with their names with:
dataArray = numpy.genfromtxt('myData.csv', delimiter = ',', names = True)
and then plot them with
matplotlib.plot.plot(dataArray)
matplotlib.plot.show()
but how do I produce a suitable legend? I thought the legend command with no parameters would suffice (e.g. matplotlib.plot.legend()
) but that is not the case. I get an error instead:
/usr/lib/python2.7/site-packages/matplotlib/axes.py:4601: UserWarning: No labeled objects found. Use label='...' kwarg on individual plots. warnings.warn("No labeled objects found. "
In other words:where do those "names" go and how can I retrieve them? Multiple searches on google, matplotlib site, and numy site produced no results.