|
From: Petr M. <mi...@ph...> - 2005-06-15 12:51:10
|
I tried to generate filename via a string function, and plot them (sometimes filenames are very long). For example: f(n)='a'.n.'.dat' plot f(1), f(2) => it should be equivalent to plot 'a1.dat', 'a2.dat'. However, gnuplot complains: warning: encountered a string when expecting a number NB: you cannot plot a string-valued function I wish it behaves like I expect, i.e. string means filename. Ethan, could you change this behaviour? --- PM |
|
From: Lutz M. <ma...@uc...> - 2005-06-15 16:39:20
|
On Wednesday 15 June 2005 05:51, Petr Mikulik wrote: > f(n)='a'.n.'.dat' > plot f(1), f(2) > > => it should be equivalent to plot 'a1.dat', 'a2.dat'. However, gnuplot I was wondering if it would be feasible to include shell-like wildcard expansion into gnuplot. For example, if there a two files a.1.dat and a.2.dat in the current working directory, plot "a.*.dat" should be interpreted as plot "a.1.dat", "a.2.dat" Is it possible to do this in a platform-independent way? I currently use the little script "pl" (http://www.phys.uni-paderborn.de/~stern/pl/) to use the globbing features of the shell, but there are quite a few things that would be much easier to do in an interactive gnuplot session. Lutz |
|
From: Ethan M. <merritt@u.washington.edu> - 2005-06-15 21:36:51
|
On Wednesday 15 June 2005 09:43 am, Lutz Maibaum wrote: > > I was wondering if it would be feasible to include shell-like wildcard > expansion into gnuplot. For example > plot "a.*.dat" > > Is it possible to do this in a platform-independent way? I currently use the > little script "pl" (http://www.phys.uni-paderborn.de/~stern/pl/) to use the > globbing features of the shell, but there are quite a few things that would > be much easier to do in an interactive gnuplot session. With the bleeding-edge cvs patch from Juergen Wieferink to implement a system() call, you could use a similar perlscript to do something along the lines of: set macros file_list = system("ls -1 a.*.dat | dirlist.pl") plot @file_list where dirlist.pl is a cleaned up version of this quick perl hack (which leaves a missing " at the start of the line and an extra ," at the end, but you get the idea) #!/usr/bin/perl -w while (<>) { s/\n/", "/; print; } In fact, if you use the equally bleeding-edge substring manipulation code you can do the cleanup inside gnuplot. The following actually works when run in the source directory using yesterday's cvs version with Juergen's patch: set macros file_list = system("ls -1 ../demo/?.dat | ./dirlist.pl") file_list = "\"".file_list file_list = file_list[0:strlen(file_list)-4] plot @file_list -- Ethan A Merritt merritt@u.washington.edu Biomolecular Structure Center Mailstop 357742 University of Washington, Seattle, WA 98195 |
|
From: <wie...@we...> - 2005-06-16 07:24:00
|
On Wednesdy, 15 June 2005 23:36, Ethan Merritt wrote:
> With the bleeding-edge cvs patch from Juergen Wieferink to implement a
> system() call, you could use a similar perlscript to do something along
> the lines of:
>
> set macros
> file_list = system("ls -1 a.*.dat | dirlist.pl")
> plot @file_list
In this special case, backtic substition will already do the job:
plot `ls -1 a.*.dat | dirlist.pl`
But feel free to try the patch and report bugs or suggest
enhancements. :-)
Juergen
|
|
From: Lutz M. <ma...@uc...> - 2005-06-17 19:44:56
|
On Thursday 16 June 2005 00:23, J=FCrgen Wieferink wrote:
> On Wednesdy, 15 June 2005 23:36, Ethan Merritt wrote:
> > set macros
> > file_list =3D system("ls -1 a.*.dat | dirlist.pl")
> > plot @file_list
>
> In this special case, backtic substition will already do the job:
>
> plot `ls -1 a.*.dat | dirlist.pl`
The problem with this is that it produces a plot with only a single item,=20
i.e., all the different files have the same (point|line)style. I was hoping=
=20
for a shortcut to automatically plot many files, each with a different styl=
e.
Lutz
|
|
From: Ethan M. <merritt@u.washington.edu> - 2005-06-17 20:14:30
|
On Friday 17 June 2005 12:48 pm, Lutz Maibaum wrote:
> On Thursday 16 June 2005 00:23, J=FCrgen Wieferink wrote:
> > On Wednesdy, 15 June 2005 23:36, Ethan Merritt wrote:
> > > set macros
> > > file_list =3D system("ls -1 a.*.dat | dirlist.pl")
> > > plot @file_list
> >
> > In this special case, backtic substition will already do the job:
> >
> > plot `ls -1 a.*.dat | dirlist.pl`
>=20
> The problem with this is that it produces a plot with only a single item,=
=20
> i.e., all the different files have the same (point|line)style. I was hopi=
ng=20
> for a shortcut to automatically plot many files, each with a different st=
yle.
Huh? No it doesn't. It expands to
plot "a.1.dat", "a.2.dat", "a.3.dat", ...
So each plot gets a new line/point style.
I know it works, because I actually tested it using the short script
in my previous Email. An even simpler demo of the principle is
gnuplot> plot `demo.pl`
where=20
#~/usr/bin/perl
# demo.pl
print " '1.dat', '2.dat', '3.dat' "
=2D-=20
Ethan A Merritt merritt@u.washington.edu
Biomolecular Structure Center
Mailstop 357742
University of Washington, Seattle, WA 98195
|
|
From: Lutz M. <ma...@uc...> - 2005-06-17 23:57:27
|
On Friday 17 June 2005 13:14, Ethan Merritt wrote: > On Friday 17 June 2005 12:48 pm, Lutz Maibaum wrote: > > The problem with this is that it produces a plot with only a single item, > > i.e., all the different files have the same (point|line)style. I was > > hoping for a shortcut to automatically plot many files, each with a > > different style. > > Huh? No it doesn't. It expands to > plot "a.1.dat", "a.2.dat", "a.3.dat", ... My apologies, I wrote my email before actually trying it out. My bad. This might afterall be exactly what I'm looking for. Lutz |
|
From: Juergen W. <wie...@fr...> - 2005-06-17 20:32:53
|
Am Freitag, 17. Juni 2005 21:48 schrieb Lutz Maibaum:
> On Thursday 16 June 2005 00:23, J=FCrgen Wieferink wrote:
> > In this special case, backtic substition will already do the job:
> >
> > plot `ls -1 a.*.dat | dirlist.pl`
>
> The problem with this is that it produces a plot with only a single item,
> i.e., all the different files have the same (point|line)style. I was hopi=
ng
> for a shortcut to automatically plot many files, each with a different
> style.
Have you actually tried? I get each file with its own line- and
pointstyle.
It may be possible to get the "dirlist.pl" simpler than the
following, though...
#!/usr/bin/perl -w
my $save =3D "\"";
while (<>) {
print $save;
s/\n/", "/;
$save =3D $_;
}
$save =3D~ s/, \"$//;
print $save;
Juergen
|