|
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
|