|
From: Mojca M. <moj...@gm...> - 2009-03-09 14:29:28
|
Hello,
I'm trying to use table header for title, but this fails to work:
plot for [n=2:26] 'mydata.dat' using 1:n title n with lines
raising an error
expecting "title" for plot
"title 2" works OK but I can only get a single label with that, "title
sprintf("%d", n)" would also help in some cases, but not this time
since the label I need is not a linear function of column.
lines 110-112 (may vary from the latest version) in datafile.c say:
} else if (!END_OF_COMMAND && isanumber(c_token)) {
column_for_key_title = int_expression();
} else /* Let the general case parser handle it */
Can someone please give me a tiny hint if there's a way to use labels
from column headers with loops?
As a fallback I can still copy-paste dozens of lines and specify
number for each column separately, but that's a bit tedious.
Thanks a lot,
Mojca
|
|
From: Juergen W. <wie...@fr...> - 2009-03-09 15:00:25
|
> I'm trying to use table header for title, but this fails to work:
> plot for [n=2:26] 'mydata.dat' using 1:n title n with lines
> raising an error
> expecting "title" for plot
>
> "title 2" works OK but I can only get a single label with that, "title
> sprintf("%d", n)" would also help in some cases, but not this time
> since the label I need is not a linear function of column.
>
> lines 110-112 (may vary from the latest version) in datafile.c say:
>
> } else if (!END_OF_COMMAND && isanumber(c_token)) {
> column_for_key_title = int_expression();
> } else /* Let the general case parser handle it */
>
> Can someone please give me a tiny hint if there's a way to use labels
> from column headers with loops?
From the code a few lines above the snippet you've shown:
plot for [n=2:26] 'mydata.dat' using 1:n title column (n) with lines
> As a fallback I can still copy-paste dozens of lines and specify
> number for each column separately, but that's a bit tedious.
>
> Thanks a lot,
> Mojca
Juergen
|
|
From: Mojca M. <moj...@gm...> - 2009-03-09 16:24:04
|
On Mon, Mar 9, 2009 at 16:00, Juergen Wieferink wrote:
>> I'm trying to use table header for title, but this fails to work:
>> plot for [n=2:26] 'mydata.dat' using 1:n title n with lines
>> raising an error
>> expecting "title" for plot
>>
>> "title 2" works OK but I can only get a single label with that, "title
>> sprintf("%d", n)" would also help in some cases, but not this time
>> since the label I need is not a linear function of column.
>>
>> lines 110-112 (may vary from the latest version) in datafile.c say:
>>
>> } else if (!END_OF_COMMAND && isanumber(c_token)) {
>> column_for_key_title = int_expression();
>> } else /* Let the general case parser handle it */
>>
>> Can someone please give me a tiny hint if there's a way to use labels
>> from column headers with loops?
>
>From the code a few lines above the snippet you've shown:
I don't (or at least didn't try hard enough to) understand much of the
code. Naively I tried changing the code into
} else if (!END_OF_COMMAND) {
if(isanumber(c_token)) {
column_for_key_title = int_expression();
} else {
column_for_key_title = (int)(real(const_express(&a)));
}
as a temporary patch to be able to experiment with the data I have,
but this is definitely the wrong way to go :) :) :)
> plot for [n=2:26] 'mydata.dat' using 1:n title column (n) with lines
Many thanks.
May I request adding a simple example like this (using for loop and
"title column()") to
http://gnuplot.sourceforge.net/demo/datastrings.html
?
Also, it would be very helpful to havea tiny bit of information or a
simple sample available under
"help for"
I have read again "help plot/title" and then "datastrings", but didn't
find the any mention of "column". May I request adding some info on
that?
Thanks a lot,
Mojca
|
|
From: Juergen W. <wie...@fr...> - 2009-03-09 16:46:37
|
> if(isanumber(c_token)) {
> column_for_key_title = int_expression();
> } else {
> column_for_key_title = (int)(real(const_express(&a)));
> }
int_expression() does exactly the same as
(int)(real(const_express(&a))).
> May I request adding a simple example like this (using for loop and
> "title column()") to
> http://gnuplot.sourceforge.net/demo/datastrings.html
> ?
Mmmh. As far as I can see this feature is undocumented up to now.
From the code,
plot ... title column(<int expr>)
does more or less the same as
plot ... title <int const>
The command
plot ... title column
without following "(" tries to guess which column to fetch data
from, which in this case might be exactly what you want. I do not
like that "column" has two different meanings.
As soon as it is documented or in the demos, this can never be
changed.
> Also, it would be very helpful to havea tiny bit of information or a
> simple sample available under
> "help for"
>
> I have read again "help plot/title" and then "datastrings", but didn't
> find the any mention of "column". May I request adding some info on
> that?
Juergen
|
|
From: Ethan A M. <merritt@u.washington.edu> - 2009-03-09 17:38:39
|
On Monday 09 March 2009, Juergen Wieferink wrote: > > > May I request adding a simple example like this (using for loop and > > "title column()") to > > http://gnuplot.sourceforge.net/demo/datastrings.html > > ? > > Mmmh. As far as I can see this feature is undocumented up to now. > >From the code, > > plot ... title column(<int expr>) > > does more or less the same as > > plot ... title <int const> > > The command > > plot ... title column > > without following "(" tries to guess which column to fetch data > from, which in this case might be exactly what you want. I do not > like that "column" has two different meanings. Yes, the code is very hackish. And column(n) seems wrong anyhow, since it is documented as returning a numerical value whereas in this case we want a string. It would be better as plot ... title stringcolumn(n) > As soon as it is documented or in the demos, this can never be > changed. > > > Also, it would be very helpful to havea tiny bit of information or a > > simple sample available under > > "help for" > > > > I have read again "help plot/title" and then "datastrings", but didn't > > find the any mention of "column". May I request adding some info on > > that? > > Juergen > -- Ethan A Merritt |
|
From: Mojca M. <moj...@gm...> - 2009-03-12 05:23:56
|
On Mon, Mar 9, 2009 at 17:46, Juergen Wieferink wrote: > >> May I request adding a simple example like this (using for loop and >> "title column()") to >> http://gnuplot.sourceforge.net/demo/datastrings.html >> ? > > From the code, > > plot ... title column(<int expr>) > > does more or less the same as > > plot ... title <int const> > > The command > > plot ... title column > > without following "(" tries to guess which column to fetch data > from, which in this case might be exactly what you want. I do not > like that "column" has two different meanings. > > As soon as it is documented or in the demos, this can never be > changed. One more question. I know that the order of reading parameters is a pretty sensitive issue in gnuplot, but it nevertheless confused me that plot for [n=2:5] 'data.dat' using 1:n title column with lines plot for [n=2:5] 'data.dat' using 1:n with lines title "something" both work while plot for [n=2:5] 'data.dat' using 1:n with lines title column fails. Is that behaviour "compatible" with previous and future versions of gnuplot? Also, I miss a bit two things. The first one being something like set format title "$a=%.2f$" or some other way to transform title. Let's say that legend (first line in data file) looks like 0.001 0.1 1 1.5 2 2.5 and that I want to use the third to sixth column and generate $a=1,0$ $a=1,5$ $a=2,0$ $a=2,5$ as the title for some LaTeX terminal. I know that I can change the label myself, but I cannot control the data and should make copies of it first. I got used to be able to change set format y so much that I sometimes want to misuse way it above its limits. The second question: is there a way to say something like for [n=2:4,6,8:20,25,30:40] ? (I know that I can construct it myself from several commands, but the for loop is really practical for long expressions that repeat themselves anyway.) Thanks a lot, Mojca |
|
From: Ethan A M. <merritt@u.washington.edu> - 2009-03-12 05:53:06
|
On Wednesday 11 March 2009, Mojca Miklavec wrote: > On Mon, Mar 9, 2009 at 17:46, Juergen Wieferink wrote: > > > >> May I request adding a simple example like this (using for loop and > >> "title column()") to > >> http://gnuplot.sourceforge.net/demo/datastrings.html > >> ? > > > > From the code, > > > > plot ... title column(<int expr>) > > > > does more or less the same as > > > > plot ... title <int const> > > > > The command > > > > plot ... title column > > > > without following "(" tries to guess which column to fetch data > > from, which in this case might be exactly what you want. I do not > > like that "column" has two different meanings. > > > > As soon as it is documented or in the demos, this can never be > > changed. > > One more question. I know that the order of reading parameters is a > pretty sensitive issue in gnuplot, but it nevertheless confused me > that > plot for [n=2:5] 'data.dat' using 1:n title column with lines > plot for [n=2:5] 'data.dat' using 1:n with lines title "something" > both work while > plot for [n=2:5] 'data.dat' using 1:n with lines title column > fails. Is that behaviour "compatible" with previous and future > versions of gnuplot? It is all part of the same problem. The code that implements the 'using ... title column(foo)' option is an ugly hack. It is a known bug, and has been on the list of things to fix for a long time. The reason it persists as a sore point rather than being fixed immediately is that in order to work properly it needs information that is only visible inside the datafile.c routines, whereas normally command options are parsed elsewhere. To fix it we will have to rearrange the code, and/or introduce new global variables, etc. > Also, I miss a bit two things. The first one being something like > set format title "$a=%.2f$" > or some other way to transform title. > > Let's say that legend (first line in data file) looks like > 0.001 0.1 1 1.5 2 2.5 > and that I want to use the third to sixth column and generate > $a=1,0$ $a=1,5$ $a=2,0$ $a=2,5$ > as the title for some LaTeX terminal. I know that I can change the > label myself, but I cannot control the data and should make copies of > it first. I got used to be able to change > set format y > so much that I sometimes want to misuse way it above its limits. Sorry, I didn't understand that. Could you try again? Are you talking about the plot title, the key entries, tick labels, or what? Anyhow, I suspect the answer in no, there is no way to do that. > The second question: is there a way to say something like > for [n=2:4,6,8:20,25,30:40] > ? (I know that I can construct it myself from several commands, but > the for loop is really practical for long expressions that repeat > themselves anyway.) That you can do: for [i in "2 4 6 8 9 10..."] Although this is a string, so long as the component 'words' are pure numbers the code should auto-convert back to integers when needed. This feature has not been extensively tested, I suspenct. So if you have problems, please complain. > Thanks a lot, > Mojca > > ------------------------------------------------------------------------------ > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are > powering Web 2.0 with engaging, cross-platform capabilities. Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > _______________________________________________ > gnuplot-beta mailing list > gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-beta > -- Ethan A Merritt Biomolecular Structure Center University of Washington, Seattle 98195-7742 |
|
From: Juergen W. <wie...@fr...> - 2009-03-12 08:17:00
|
Am Donnerstag, 12. März 2009 schrieb Ethan A Merritt: > On Wednesday 11 March 2009, Mojca Miklavec wrote: > > One more question. I know that the order of reading parameters is a > > pretty sensitive issue in gnuplot, but it nevertheless confused me > > that > > plot for [n=2:5] 'data.dat' using 1:n title column with lines > > plot for [n=2:5] 'data.dat' using 1:n with lines title "something" > > both work while > > plot for [n=2:5] 'data.dat' using 1:n with lines title column > > fails. Is that behaviour "compatible" with previous and future > > versions of gnuplot? > > It is all part of the same problem. The code that implements the > 'using ... title column(foo)' option is an ugly hack. > It is a known bug, and has been on the list of things to fix for a long > time. > > The reason it persists as a sore point rather than being fixed > immediately is that in order to work properly it needs information that > is only visible inside the datafile.c routines, whereas normally command > options are parsed elsewhere. To fix it we will have to rearrange the > code, and/or introduce new global variables, etc. One option would be to put the parsing code into a separate function in datafile.c which is called on a keyword not known within plot?d.c. Though I suspect that this would not be too easy. I do not know how to set the default title then. That said, I think it would have been a good idea to name the title option in datafile.c something like "autot$itle". Juergen |
|
From: Ethan A M. <merritt@u.washington.edu> - 2009-03-13 05:23:24
|
On Thursday 12 March 2009, Juergen Wieferink wrote:
> Am Donnerstag, 12. März 2009 schrieb Ethan A Merritt:
> > On Wednesday 11 March 2009, Mojca Miklavec wrote:
> > > One more question. I know that the order of reading parameters is a
> > > pretty sensitive issue in gnuplot, but it nevertheless confused me
> > > that
> > > plot for [n=2:5] 'data.dat' using 1:n title column with lines
> > > plot for [n=2:5] 'data.dat' using 1:n with lines title "something"
> > > both work while
> > > plot for [n=2:5] 'data.dat' using 1:n with lines title column
> > > fails. Is that behaviour "compatible" with previous and future
> > > versions of gnuplot?
> >
> > It is all part of the same problem. The code that implements the
> > 'using ... title column(foo)' option is an ugly hack.
> > It is a known bug, and has been on the list of things to fix for a long
> > time.
> >
> > The reason it persists as a sore point rather than being fixed
> > immediately is that in order to work properly it needs information that
> > is only visible inside the datafile.c routines, whereas normally command
> > options are parsed elsewhere. To fix it we will have to rearrange the
> > code, and/or introduce new global variables, etc.
>
> One option would be to put the parsing code into a separate function
> in datafile.c which is called on a keyword not known within
> plot?d.c. Though I suspect that this would not be too easy. I do
> not know how to set the default title then.
You are right. It can be done that way.
I have so modified the parsing code, which now accepts:
plot ... title columnheader
plot ... title columnheader(N)
The option is now handled by the normal title parsing code, so there is
no strangeness with the order of title options on the command line.
The original form of the command, which was never documented but was
used in several of the demos, is now deprecated. However it still works
if you ./configure --enable-backwards-compatibility
Thus
plot ... using 1 title 1
should be re-written using any of the following:
plot ... using 1 title col
plot ... using 1 title columnhead(1)
set key autotitle columnhead
plot ... using 1
The change leaves one chunk of dead code in df_open() that looks like it
used to handle some exceptional case, but can now never be reached.
This may mean that the exceptional case is now broken, but I haven't
been able to work out what it was :-/ Oh well.
--
Ethan A Merritt
|
|
From: Mojca M. <moj...@gm...> - 2009-03-13 09:01:51
|
On Fri, Mar 13, 2009 at 06:23, Ethan A Merritt wrote:
>
> I have so modified the parsing code, which now accepts:
> plot ... title columnheader
> plot ... title columnheader(N)
> The option is now handled by the normal title parsing code, so there is
> no strangeness with the order of title options on the command line.
>
> The original form of the command, which was never documented but was
> used in several of the demos, is now deprecated. However it still works
> if you ./configure --enable-backwards-compatibility
> Thus
> plot ... using 1 title 1
> should be re-written using any of the following:
> plot ... using 1 title col
> plot ... using 1 title columnhead(1)
> set key autotitle columnhead
> plot ... using 1
>
> The change leaves one chunk of dead code in df_open() that looks like it
> used to handle some exceptional case, but can now never be reached.
> This may mean that the exceptional case is now broken, but I haven't
> been able to work out what it was :-/ Oh well.
Hello,
First - thanks a lot for clearing it up.
One more tiny question from a dumb user. Let's assume that the data
has a title row, like this:
# first column is quarter, second and third are data for specific year
# zero is just a placeholder
# this is header
0 2000 2001
# this is data
1 50 55
2 15 30
3 20 40
4 30 53
I can now say
plot for[n=2:3] "data.dat" using 1:n title columnhead
which triggers the first row in data to be handled as header. What if
I want that header line to be simply ignored?
The command
unset key
plot for[n=2:3] "data.dat" using 1:n
alone will treat the first row as part of data.
I didn't try it, but I guess that
unset key autotitle columnhead
doesn't work as such :) :) :)
Maybe
set key autotitle columnhead
plot for[n=2:3] "data.dat" using 1:n notitle
? But I still hope that there's a some better option.
Thanks a lot,
Mojca
|
|
From: Ethan M. <merritt@u.washington.edu> - 2009-03-13 16:26:18
|
On Friday 13 March 2009 02:01:48 Mojca Miklavec wrote: > One more tiny question from a dumb user. Let's assume that the data > has a title row, like this: > > # first column is quarter, second and third are data for specific year > # zero is just a placeholder > # this is header > 0 2000 2001 > # this is data > 1 50 55 > 2 15 30 > 3 20 40 > 4 30 53 > > I can now say > plot for[n=2:3] "data.dat" using 1:n title columnhead > which triggers the first row in data to be handled as header. What if > I want that header line to be simply ignored? > The command > unset key > plot for[n=2:3] "data.dat" using 1:n > alone will treat the first row as part of data. > > I didn't try it, but I guess that > unset key autotitle columnhead > doesn't work as such :) :) :) You still haven't explained what you would like the result to be. Do you not want a key at all? unset key plot .... Do you want a key, but have this particular column omitted from the key? set key autotitle columnheader plot foo using 2 notitle, '' using 3 notitle > Maybe > set key autotitle columnhead > plot for[n=2:3] "data.dat" using 1:n notitle > ? But I still hope that there's a some better option. Better in what way? If that is what you want, how else would you specify it? Or maybe the whole issue of plot titles is not relevant... Are you asking how to skip the first line of a data file? plot '< tail +2 file.dat' .... Or maybe: plot 'file.dat' every ::2 using ... -- Ethan A Merritt |
|
From: Mojca M. <moj...@gm...> - 2009-03-13 10:09:24
|
On Thu, Mar 12, 2009 at 06:52, Ethan A Merritt wrote:
> On Wednesday 11 March 2009, Mojca Miklavec wrote:
>
>> Also, I miss a bit two things. The first one being something like
>> set format title "$a=%.2f$"
>> or some other way to transform title.
>>
>> Let's say that legend (first line in data file) looks like
>> 0.001 0.1 1 1.5 2 2.5
>> and that I want to use the third to sixth column and generate
>> $a=1,0$ $a=1,5$ $a=2,0$ $a=2,5$
>> as the title for some LaTeX terminal. I know that I can change the
>> label myself, but I cannot control the data and should make copies of
>> it first. I got used to be able to change
>> set format y
>> so much that I sometimes want to misuse way it above its limits.
>
> Sorry, I didn't understand that. Could you try again?
I would like to do something like this, but with datafiles:
plot [0:1] for[n=1:4] sin(n*x/pi) t sprintf("sin(%dx)", n)
Let's say that my data looks like this:
# this is header
0 0.5 1 1.5 2
# this is data
...
I didn't recompile gnuplot with your most recent modifications, so
maybe the behaviour is different now, but with older gnuplot trying to
use
plot for[n=1:5] "data.dat" using n t sprintf("$%.1f\\pi$", column(n))
as an equivalent of
# a command to ignore the first row should come here first
plot \
"data.dat" using 1 t '$0.0\pi$',\
"data.dat" using 2 t '$0.5\pi$',\
"data.dat" using 3 t '$1.0\pi$',\
"data.dat" using 4 t '$1.5\pi$',\
"data.dat" using 5 t '$2.0\pi$'
didn't work.
In gnuplot I often use syntax
set logscale y
set format y "$10^{%T}$"
in order to print 10^1, 10^2, 10^3 on y axis (in LaTeX/ConTeXt) or
(double misuse, I'm referring to "set format x"):
set format x "$%.1f\\pi$"
plot [0:2] for[n=1:4] sin(n*x*pi) t sprintf("sin(%dx)", n)
to print 0.0π, 0.5π, 1.0π, 1.5π, 2.0π on x axis (that's hopefully
unicode "pi" in case that mail agents have probems with it).
So I would imagine that something like
set key autotitle columnhead format "$%.1f\\pi$"
plot for[n=1:5] "data.dat" using n
could do the dirty trick.
But I would be happy enough to have
plot for[n=1:5] "data.dat" using n t sprintf("$%.1f\\pi$", column(n))
working.
> Are you talking about the plot title, the key entries, tick labels, or what?
> Anyhow, I suspect the answer in no, there is no way to do that.
>> The second question: is there a way to say something like
>> for [n=2:4,6,8:20,25,30:40]
>> ? (I know that I can construct it myself from several commands, but
>> the for loop is really practical for long expressions that repeat
>> themselves anyway.)
>
> That you can do:
>
> for [i in "2 4 6 8 9 10..."]
>
> Although this is a string, so long as the component 'words' are
> pure numbers the code should auto-convert back to integers when needed.
> This feature has not been extensively tested, I suspenct.
> So if you have problems, please complain.
Wow! Great, thanks a lot. I didn't know that it can work that way.
I'll test and report in case of problems.
Mojca
|
|
From: Ethan M. <merritt@u.washington.edu> - 2009-03-13 16:35:12
|
On Friday 13 March 2009 03:09:16 Mojca Miklavec wrote:
> On Thu, Mar 12, 2009 at 06:52, Ethan A Merritt wrote:
> > On Wednesday 11 March 2009, Mojca Miklavec wrote:
> >
> >> Also, I miss a bit two things. The first one being something like
> >> set format title "$a=%.2f$"
> >> or some other way to transform title.
> >>
> >> Let's say that legend (first line in data file) looks like
> >> 0.001 0.1 1 1.5 2 2.5
> >> and that I want to use the third to sixth column and generate
> >> $a=1,0$ $a=1,5$ $a=2,0$ $a=2,5$
> >> as the title for some LaTeX terminal. I know that I can change the
> >> label myself, but I cannot control the data and should make copies of
> >> it first. I got used to be able to change
> >> set format y
> >> so much that I sometimes want to misuse way it above its limits.
> >
> > Sorry, I didn't understand that. Could you try again?
>
> I would like to do something like this, but with datafiles:
> plot [0:1] for[n=1:4] sin(n*x/pi) t sprintf("sin(%dx)", n)
>
> Let's say that my data looks like this:
>
> # this is header
> 0 0.5 1 1.5 2
> # this is data
> ...
The only thing I can think of is
set key title "sin(ax) for a ="
set key autotitle columnhead
> I didn't recompile gnuplot with your most recent modifications, so
> maybe the behaviour is different now, but with older gnuplot trying to
> use
> plot for[n=1:5] "data.dat" using n t sprintf("$%.1f\\pi$", column(n))
No. That has never worked, and was never intended to work.
The function column(n), if it were legal at all in this context,
would be called for every line of data, which makes no sense.
> as an equivalent of
> # a command to ignore the first row should come here first
> plot \
> "data.dat" using 1 t '$0.0\pi$',\
> "data.dat" using 2 t '$0.5\pi$',\
> "data.dat" using 3 t '$1.0\pi$',\
> "data.dat" using 4 t '$1.5\pi$',\
> "data.dat" using 5 t '$2.0\pi$'
> didn't work.
>
> In gnuplot I often use syntax
> set logscale y
> set format y "$10^{%T}$"
> in order to print 10^1, 10^2, 10^3 on y axis (in LaTeX/ConTeXt) or
> (double misuse, I'm referring to "set format x"):
> set format x "$%.1f\\pi$"
> plot [0:2] for[n=1:4] sin(n*x*pi) t sprintf("sin(%dx)", n)
> to print 0.0π, 0.5π, 1.0π, 1.5π, 2.0π on x axis (that's hopefully
> unicode "pi" in case that mail agents have probems with it).
>
> So I would imagine that something like
> set key autotitle columnhead format "$%.1f\\pi$"
> plot for[n=1:5] "data.dat" using n
> could do the dirty trick.
>
> But I would be happy enough to have
> plot for[n=1:5] "data.dat" using n t sprintf("$%.1f\\pi$", column(n))
> working.
Nope. sorry. There is no way to do that.
The plot title and other titles and labels are simply strings, not format
statements. There is a reason why the one command is 'set format', while the
other commands are 'set title' or 'set label'.
--
Ethan A Merritt
|
|
From: James R. V. Z. <jr...@co...> - 2009-03-16 02:16:18
|
Ethan Merritt wrote:
> On Thursday 12 March 2009, Juergen Wieferink wrote:
> I have [...] modified the parsing code, which now accepts:
> plot ... title columnheader
> plot ... title columnheader(N)
> The option is now handled by the normal title parsing code, so there is
> no strangeness with the order of title options on the command line.
>
> The original form of the command, which was never documented but was
> used in several of the demos, is now deprecated. However it still works
> if you ./configure --enable-backwards-compatibility
> Thus
> plot ... using 1 title 1
> should be re-written using any of the following:
> plot ... using 1 title col
> plot ... using 1 title columnhead(1)
> set key autotitle columnhead
> plot ... using 1
Suppose I have data that looks like this:
1.000000 2.000000 2.000000
2.000000 1.000000 2.000000
3.000000 0.666667 2.000000
4.000000 0.500000 2.000000
1.000000 3.000000 3.000000
2.000000 1.500000 3.000000
3.000000 1.000000 3.000000
4.000000 0.750000 3.000000
1.000000 4.000000 4.000000
2.000000 2.000000 4.000000
3.000000 1.333333 4.000000
4.000000 1.000000 4.000000
...
I would like to plot each datablock with its own title taken from the
third column. I can use
plot for [n=0:3] 'lab.dat' in n title 3
except that the first line of each datablock is not plotted.
Maybe what I want is
plot for [n=0:3] 'lab.dat' in n title datastring(3)
but that isn't implemented?
BTW my application is a simulation where several of the columns have
input parameters, and the rest of the columns have outputs. I can
plot one output as a function of two inputs using splot. However, to
make it possible to actually read values off the curves, I would like
to plot iso-<whatever> lines: output as a function of one input
parameter, for selected values of a second parameter, and all other
parameters held constant. It would be very helpful to get the curve
labels from the data file itself.
- Jim Van Zandt
|
|
From: Ethan A M. <merritt@u.washington.edu> - 2009-03-16 04:35:58
|
On Sunday 15 March 2009, James R. Van Zandt wrote:
>
> Ethan Merritt wrote:
> > On Thursday 12 March 2009, Juergen Wieferink wrote:
> > I have [...] modified the parsing code, which now accepts:
> > plot ... title columnheader
> > plot ... title columnheader(N)
> > The option is now handled by the normal title parsing code, so there is
> > no strangeness with the order of title options on the command line.
> >
> > The original form of the command, which was never documented but was
> > used in several of the demos, is now deprecated. However it still works
> > if you ./configure --enable-backwards-compatibility
> > Thus
> > plot ... using 1 title 1
> > should be re-written using any of the following:
> > plot ... using 1 title col
> > plot ... using 1 title columnhead(1)
> > set key autotitle columnhead
> > plot ... using 1
>
> Suppose I have data that looks like this:
>
> 1.000000 2.000000 2.000000
> 2.000000 1.000000 2.000000
> 3.000000 0.666667 2.000000
> 4.000000 0.500000 2.000000
>
>
> 1.000000 3.000000 3.000000
> 2.000000 1.500000 3.000000
> 3.000000 1.000000 3.000000
> 4.000000 0.750000 3.000000
>
>
> 1.000000 4.000000 4.000000
> 2.000000 2.000000 4.000000
> 3.000000 1.333333 4.000000
> 4.000000 1.000000 4.000000
> ...
>
> I would like to plot each datablock with its own title taken from the
> third column. I can use
>
> plot for [n=0:3] 'lab.dat' in n title 3
>
> except that the first line of each datablock is not plotted.
Of course it isn't. You have told the program that the first line
contains labels, not data.
> Maybe what I want is
>
> plot for [n=0:3] 'lab.dat' in n title datastring(3)
>
> but that isn't implemented?
I don't know, because I don't quite understand what you are trying to do.
How can every line of the data file contain a plot title?
I could understand using each 3rd column value as a point symbol,
or a color, or an xticlabel, etc, but it doesn't make sense to have
multiple titles for the same plot.
Maybe you are over-thinking this? If that is really what your data file
looks like, maybe you just want
plot for [n=0:3] 'lab.dat' in n title sprintf("Data block %d",n)
Ethan
>
> BTW my application is a simulation where several of the columns have
> input parameters, and the rest of the columns have outputs. I can
> plot one output as a function of two inputs using splot. However, to
> make it possible to actually read values off the curves, I would like
> to plot iso-<whatever> lines: output as a function of one input
> parameter, for selected values of a second parameter, and all other
> parameters held constant. It would be very helpful to get the curve
> labels from the data file itself.
Sorry, I still don't follow what you are aiming for.
You are doing something to select coordinate pairs from a subset of
lines in the file. OK. But whatever set you pick within a single "plot"
command can have only one title, right?
> - Jim Van Zandt
>
|
|
From: James R. V. Z. <jr...@co...> - 2009-03-17 02:10:27
|
Ethan A Merritt wrote:
> On Sunday 15 March 2009, James R. Van Zandt wrote:
> >
...
> >
> > I would like to plot each datablock with its own title taken from the
> > third column. I can use
> >
> > plot for [n=0:3] 'lab.dat' in n title 3
> >
> > except that the first line of each datablock is not plotted.
>
> Of course it isn't. You have told the program that the first line
> contains labels, not data.
Right. But I would like a way to tell the program that the first line
contains data that I would *also* like to use for labels.
> > Maybe what I want is
> >
> > plot for [n=0:3] 'lab.dat' in n title datastring(3)
> >
> > but that isn't implemented?
>
> I don't know, because I don't quite understand what you are trying to do.
> How can every line of the data file contain a plot title?
I'm not necessarily plotting every datablock. But the significant
thing about a datablock I do plot is that it has a constant value in
the third column. So naturally I want to use that value for the
title.
> I could understand using each 3rd column value as a point symbol,
> or a color, or an xticlabel, etc, but it doesn't make sense to have
> multiple titles for the same plot.
No, just one title.
> Maybe you are over-thinking this? If that is really what your data file
> looks like, maybe you just want
>
> plot for [n=0:3] 'lab.dat' in n title sprintf("Data block %d",n)
No, because it's the parameter value rather than the block number that
is significant. In this particular case I could use
plot for [n=0:3] 'lab.dat' in n title sprintf("parameter = %d",n+2)
but that would not work if the parameter values were not linearly
spaced, and would have to be manually adjusted every time the
parameter values changed.
> > BTW my application is a simulation where several of the columns have
> > input parameters, and the rest of the columns have outputs. I can
> > plot one output as a function of two inputs using splot. However, to
> > make it possible to actually read values off the curves, I would like
> > to plot iso-<whatever> lines: output as a function of one input
> > parameter, for selected values of a second parameter, and all other
> > parameters held constant. It would be very helpful to get the curve
> > labels from the data file itself.
>
> Sorry, I still don't follow what you are aiming for.
> You are doing something to select coordinate pairs from a subset of
> lines in the file. OK. But whatever set you pick within a single "plot"
> command can have only one title, right?
Let me try again. Assuming this data file:
# R I V
2000 0.001000 2
2750 0.000727 2
3500 0.000571 2
4250 0.000471 2
5000 0.000400 2
2000 0.002500 5
2750 0.001818 5
3500 0.001429 5
4250 0.001176 5
5000 0.001000 5
2000 0.005000 10
2750 0.003636 10
3500 0.002857 10
4250 0.002353 10
5000 0.002000 10
I'd like to plot current as a function of resistance, with the title
for each curve giving the voltage.
- Jim Van Zandt
|
|
From: Mojca M. <moj...@gm...> - 2009-03-17 11:02:29
|
On Tue, Mar 17, 2009 at 03:29, James R. Van Zandt wrote: > > Let me try again. Assuming this data file: > > # R I V > 2000 0.001000 2 > 2750 0.000727 2 > 3500 0.000571 2 > 4250 0.000471 2 > 5000 0.000400 2 > > > 2000 0.002500 5 > 2750 0.001818 5 > 3500 0.001429 5 > 4250 0.001176 5 > 5000 0.001000 5 > > > 2000 0.005000 10 > 2750 0.003636 10 > 3500 0.002857 10 > 4250 0.002353 10 > 5000 0.002000 10 > > I'd like to plot current as a function of resistance, with the title > for each curve giving the voltage. I understand your question, but if I had this kind of data, I would transform the data first into this form: # first column: R # header: I # data: V R 2 5 10 2000 0.001000 0.002500 0.005000 2750 0.000727 0.001818 0.003636 3500 0.000571 0.001429 0.002857 4250 0.000471 0.001176 0.002353 5000 0.000400 0.001000 0.002000 set key autotitle columnhead plot for [n=2:4] 'lab.dat' using 1:n (Nobody can guarantee that the label in each row is identical in your case.) Mojca |
|
From: James R. V. Z. <jr...@co...> - 2009-03-24 21:44:03
|
Mojca Miklavec <moj...@gm...> wrote:
>On Tue, Mar 17, 2009 at 03:29, James R. Van Zandt wrote:
>>
>> Let me try again. Assuming this data file:
>>
>> # R I V
>> 2000 0.001000 2
>> 2750 0.000727 2
>> 3500 0.000571 2
>> 4250 0.000471 2
>> 5000 0.000400 2
>>
>>
>> 2000 0.002500 5
>> 2750 0.001818 5
>> 3500 0.001429 5
>> 4250 0.001176 5
>> 5000 0.001000 5
>>
>>
>> 2000 0.005000 10
>> 2750 0.003636 10
>> 3500 0.002857 10
>> 4250 0.002353 10
>> 5000 0.002000 10
>>
>> I'd like to plot current as a function of resistance, with the title
>> for each curve giving the voltage.
>
>I understand your question, but if I had this kind of data, I would
>transform the data first into this form:
>
># first column: R
># header: I
># data: V
>R 2 5 10
>2000 0.001000 0.002500 0.005000
>2750 0.000727 0.001818 0.003636
>3500 0.000571 0.001429 0.002857
>4250 0.000471 0.001176 0.002353
>5000 0.000400 0.001000 0.002000
>
>set key autotitle columnhead
>plot for [n=2:4] 'lab.dat' using 1:n
That kind of transformation looks much too fragile to me. I suppose I
could plot the entire data file twice, once without titles (so every
point is plotted) and again, with matching line styles, taking the
titles from the first row of each datablock. Still error-prone. Or I
could duplicate the first line in each datablock, so there is one copy
for the title and a second copy to be plotted. Not a big deal if you
only do it once.
>(Nobody can guarantee that the label in each row is identical in your case.)
I can guarantee it. I would hardly ask anyone else to. :-)
- Jim Van Zandt
|