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