I have a lot of experimental datafiles I would like to plot first and check, if they can be used for further analysis or not. To avoid importing every single file I used FileNames and than mapping. This creates a plot grid, works fine so far.
I would now like to label each of the plots by the FileBaseName for quick identification. Is this possible?
Here is what I tried so far:
files = FileNames["*.dat", {"path_to_data_directory"}];
data = Import /@ files;
ListLinePlot[#,
InterpolationOrder -> 0,
PlotLabel -> FileBaseName[#] & /@ files] & /@ data
As I said, the plotting works perfect, but PlotLabel
gives labeling of the plots with every single plot is labeled by the base name of the first file.
Any suggestions?
f[#, opt -> FileBaseName[#] & /@ {file1, file2}] & /@ {data1, data2}
. Then, take a look atMapThread
. $\endgroup$ – Kuba♦ Feb 22 '16 at 17:53ListLinePlot[Import[#], InterpolationOrder -> 0, PlotLabel -> FileBaseName[#] ] & /@ files
. (Unless of course you want to keep all thedata
in memory for other purpose.) $\endgroup$ – george2079 Feb 22 '16 at 18:24Import
every file twice, although if the performance is acceptable there is no real harm in it. Another tack on this is when you import dodata={#,Import[#]}&/@files
, then you are carrying around a list with the data and the associated name together. $\endgroup$ – george2079 Feb 22 '16 at 18:43