From: sfeam <sf...@us...> - 2017-07-27 15:48:15
|
On Thursday, 27 July 2017 09:34:18 theozh wrote: > Hi, > I would like to plot many files (under Windows) in a multiplot > environment using a loop. > The filenames without extensions are e.g., > Data1a, Data1b, Data2, Data3, Data3a, Data3b, Data5a, ... > > set multiplot layout 3,3 > do for [i = 1:9] { > FileList = system("dir /B /S Data".i."*.dat") > plot for [FileName in FileList] FileName u 1:2 w l > } > unset multiplot > > I want all Data1 in one plot, all Data2 in the next plot, etc. > It varies how many plots (a,b,c,...) of each. > However, it could also happen that, e.g. there is no "Data4" file. > > In case there is no matching file in the directory gnuplot exits with a > message "popen failed" and FileList is not changed. The issue is not the missing file per se, it's that apparently Windows considers this sufficiently severe to return an error code from the "dir" command. It isn't a problem on unix/linux, where "ls" will print a warning message but returns success. So I imagine it would be sufficient to wrap your "dir" command in a script MYDIR that always returns success even if the real "dir" fails: FileList = system( "MYDIR Data".1."*.dat" ) > How to ignore "pope failed" and instead just create an empty plot? You can't ignore "popen failed", you'll have to prevent it from failing. > Thank you for any hints. |