|
From: Jacob G. <jac...@gm...> - 2014-12-07 13:19:03
|
Hi list,
I have several datafiles, which I'd like to plot together on one plot as
smooth lines, but I'd also like to highlight each maximum
With one file, I'm able to do
plot 'file' smooth csplines
stats 'file'
replot file every::STATS_index_max::STATS_index_max notitle
And get what I want.
I tried expanding this with loops:
filenames = "one two three four"
plot for [file in filenames] file.".txt" \
smooth csplines
do for [n=1:4] {
file=word(filenames,n).'.txt'
stats file
replot file every ::STATS_index_max::STATS_index_max notitle
}
This plots the csplines fine, but when replotting, I get four occurrences of
warning: Skipping unreadable file "four"
It seems this is some sort of name conflict by reusing the variable files;
I was able to solve this by using a different variable, but I'd like to
understand what happened.
Even after changing the file name, I don't get four separate maxima.
Instead, I get the maximum from "four" plotted four times.
Is it possible to do this with loops or do I need to write one big plotting
command to do it all at once?
Thanks
Jake
|
|
From: Jacob G. <jac...@gm...> - 2014-12-08 12:25:11
|
Thanks for the tips.
On Sun Dec 07 2014 at 8:48:29 PM Ethan A Merritt <EAM...@gm...>
wrote:
> files = "one two three four"
>
> do for [name in files] {
> stats name.'.txt' using 1 prefix name
> }
I get an "illegal prefix" error when I try this. It seems like it doesn't
like taking the prefix from a variable, but I can't find any discussion of
this on the web.
Any ideas?
Jake
|
|
From: Ethan M. <eam...@gm...> - 2014-12-08 16:47:49
|
On Mon, Dec 8, 2014 at 4:25 AM, Jacob Gerlach <jac...@gm...> wrote:
> Thanks for the tips.
>
> On Sun Dec 07 2014 at 8:48:29 PM Ethan A Merritt <EAM...@gm...>
> wrote:
>>
>> files = "one two three four"
>>
>> do for [name in files] {
>> stats name.'.txt' using 1 prefix name
>> }
>
>
> I get an "illegal prefix" error when I try this. It seems like it doesn't
> like taking the prefix from a variable, but I can't find any discussion of
> this on the web.
I use this construction in scripts myself, so I am sure there is no
such limitation in general. The prefix must conform to normal
limitations for variable names, however. It cannot start with a digit
or contain punctuation marks.
Ethan
> Any ideas?
>
> Jake
|
|
From: Jacob G. <jac...@gm...> - 2014-12-08 18:48:15
|
On Mon Dec 08 2014 at 11:47:43 AM Ethan Merritt <eam...@gm...> wrote:
> The prefix must conform to normal
> limitations for variable names, however. It cannot start with a digit
> or contain punctuation marks.
>
Ah. I had hyphens in my filenames. Removing them cleared that error, but
now I get:
warning: Skipping data file with no valid points
I tried a non loop minimal example to ensure it's not a problem with my
datafile:
stats 'file.txt' prefix "file"
plot 'file.txt' every::file_index_max::file_index_max
This works fine.
Is there a way to look at what a command expanded into after the variables
were substituted?
On Mon Dec 08 2014 at 11:47:43 AM Ethan Merritt <eam...@gm...> wrote:
> On Mon, Dec 8, 2014 at 4:25 AM, Jacob Gerlach <jac...@gm...>
> wrote:
> > Thanks for the tips.
> >
> > On Sun Dec 07 2014 at 8:48:29 PM Ethan A Merritt <EAM...@gm...>
> > wrote:
> >>
> >> files = "one two three four"
> >>
> >> do for [name in files] {
> >> stats name.'.txt' using 1 prefix name
> >> }
> >
> >
> > I get an "illegal prefix" error when I try this. It seems like it
> doesn't
> > like taking the prefix from a variable, but I can't find any discussion
> of
> > this on the web.
>
> I use this construction in scripts myself, so I am sure there is no
> such limitation in general. The prefix must conform to normal
> limitations for variable names, however. It cannot start with a digit
> or contain punctuation marks.
>
> Ethan
>
> > Any ideas?
> >
> > Jake
>
|
|
From: Ethan A M. <EAM...@gm...> - 2014-12-08 02:23:59
|
On Sunday, 07 December 2014 01:18:56 PM Jacob Gerlach wrote:
> Hi list,
>
> I have several datafiles, which I'd like to plot together on one plot as
> smooth lines, but I'd also like to highlight each maximum
>
> With one file, I'm able to do
>
> plot 'file' smooth csplines
> stats 'file'
> replot file every::STATS_index_max::STATS_index_max notitle
>
> And get what I want.
> I tried expanding this with loops:
>
> filenames = "one two three four"
>
> plot for [file in filenames] file.".txt" \
> smooth csplines
>
> do for [n=1:4] {
> file=word(filenames,n).'.txt'
> stats file
> replot file every ::STATS_index_max::STATS_index_max notitle
> }
>
> This plots the csplines fine, but when replotting, I get four occurrences of
> warning: Skipping unreadable file "four"
>
> It seems this is some sort of name conflict by reusing the variable files;
> I was able to solve this by using a different variable, but I'd like to
> understand what happened.
>
> Even after changing the file name, I don't get four separate maxima.
> Instead, I get the maximum from "four" plotted four times.
>
> Is it possible to do this with loops or do I need to write one big plotting
> command to do it all at once?
files = "one two three four"
do for [name in files] {
stats name.'.txt' using 1 prefix name
}
plot for [name in files] name.'.txt' every :: name."_index_max" :: name."_index_max", \
for [name in files] name.'.txt'
But probably I would do it differently. Something like
set for [name in files] arrow from name."index_max", 0 to name."_index_max", name."_max"
plot for [name in filex] name.'.txt' using 1
Ethan
|