Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Scaling a curve

10 views
Skip to first unread message

Dieter Britz

unread,
Apr 24, 2013, 7:58:31 AM4/24/13
to
My apologies if I have asked this before (but I don't think I have):
I want to scale a curve by diving the curve height by pi/2 = 0.6366.
I see that I can get a function of an axis by using "using", so why
doesn't this work:

using 1:($2*0.6366)

?

In the manual, I find

using 1:(log($2))

which led me to think this should work. Maybe even

using 1:($2*2/pi)

--
Dieter Britz

Christoph Bersch

unread,
Apr 24, 2013, 8:42:07 AM4/24/13
to
Hi,

Am 24.04.2013 13:58, schrieb Dieter Britz:
> My apologies if I have asked this before (but I don't think I have):
> I want to scale a curve by diving the curve height by pi/2 = 0.6366.
> I see that I can get a function of an axis by using "using", so why
> doesn't this work:
>
> using 1:($2*0.6366)

what does it mean "doesn't work"? How does your complete plot statement
look like? Are you using functions, or data?

Christoph

Dieter Britz

unread,
Apr 24, 2013, 8:46:59 AM4/24/13
to
Sorry! I just discovered a simple error in the script. The
error message ended with an arrow that I thought was pointing
at the rescaling bit, but it didn't.

--
Dieter Britz

Karl

unread,
Apr 24, 2013, 8:50:22 AM4/24/13
to


On 24.04.2013 13:58, Dieter Britz wrote:
> My apologies if I have asked this before (but I don't think I have):
> I want to scale a curve by diving the curve height by pi/2 = 0.6366.

?!? 0.637 is a bit more than pi/5!

> I see that I can get a function of an axis by using "using", so why
> doesn't this work:
>
> using 1:($2*0.6366)

Should definitely work. What do you get?

>
> ?
>
> In the manual, I find
>
> using 1:(log($2))
>
> which led me to think this should work. Maybe even
>
> using 1:($2*2/pi)

Will work too, and give you the values you want.

Karl

Dieter Britz

unread,
Apr 24, 2013, 8:54:16 AM4/24/13
to
However, when I fixed it, I still get an error and I can't see why.
The plot lines are

plot 'hhcurr.2.dat' using 1:($2*0.6366) w l lt 2, 'dhcurr2.dat' w l lt
1, \
'hhcurr.3.dat' using 1:($2*0.6366) w l lt 2, 'dhcurr3.dat' w l lt
1, \
'hhcurr.5.dat' using 1:($2*0.6366) w l lt 2, 'dhcurr5.dat' w l lt
1, \
'hhcurr.7.dat' using 1:($2*0.6366) w l lt 2, 'dhcurr7.dat' w l lt
1, \
'hhcurr.10.dat' using 1:($2*0.6366) w l lt 2, 'dhcurr10.dat' w l lt
1

(Previously I had left out some quote marks). I get the message

gnuplot> plot 'hhcurr.2.dat' using 1:(*0.6366) w l lt 2, 'dhcurr2.dat' w
l lt 1, 'hhcurr.3.dat' using 1:(*0.6366) w l lt 2, 'dhcurr3.dat' w
l lt 1, 'hhcurr.5.dat' using 1:(*0.6366) w l lt 2, 'dhcurr5.dat' w
l lt 1, 'hhcurr.7.dat' using 1:(*0.6366) w l lt 2, 'dhcurr7.dat' w
l lt 1, 'hhcurr.10.dat' using 1:(*0.6366) w l lt 2, 'dhcurr10.dat'
w l lt 1
^
line 0: invalid expression

but I don't see any error in that. ??
--
Dieter Britz

Christoph Bersch

unread,
Apr 24, 2013, 9:13:24 AM4/24/13
to
Hi,

for testing, you should use less plot lines, then you would see

Am 24.04.2013 14:54, schrieb Dieter Britz:
>
> The plot lines are
>
> plot 'hhcurr.2.dat' using 1:($2*0.6366) w l lt 2
[...]
>
> (Previously I had left out some quote marks). I get the message
>
> gnuplot> plot 'hhcurr.2.dat' using 1:(*0.6366) w l lt 2
> ^
> line 0: invalid expression

where the error exactly is.
How do you invoke the script? Is there any bash script, or similar
involved? Then you would need to escape the dollar sign, e.g.

plot 'hhcurr.2.dat' using 1:(\$2*0.6366) w l lt 2

Christoph

Karl

unread,
Apr 24, 2013, 9:29:21 AM4/24/13
to


On 24.04.2013 15:13, Christoph Bersch wrote:
> Am 24.04.2013 14:54, schrieb Dieter Britz:
>> gnuplot> plot 'hhcurr.2.dat' using 1:(*0.6366) w l lt 2
>> ^
>> line 0: invalid expression

> How do you invoke the script? Is there any bash script, or similar
> involved? Then you would need to escape the dollar sign, e.g.

I´d say he loads the script from another gp-script using "call".
Then the dollar signs in the "using" statement need to be doubled.

plot '' using 1:($$2/pi*2)


Karl

Christoph Bersch

unread,
Apr 24, 2013, 9:34:45 AM4/24/13
to
Am 24.04.2013 15:29, schrieb Karl:
>
> I´d say he loads the script from another gp-script using "call".
> Then the dollar signs in the "using" statement need to be doubled.

Ok, I never used that one. We'll see :-)

Christoph

sfeam

unread,
Apr 24, 2013, 11:00:37 AM4/24/13
to
If there are multiple levels of scripting, interpretation of
reserved characters like $ can be problematic. In this case
it would be safer to avoid the problem by saying

plot '' using 1:(column(2)* 2.0/pi)

Dieter Britz

unread,
Apr 25, 2013, 5:55:49 AM4/25/13
to
The backslash did the trick, thanks! Yes, this is part of a shell
script under .bashrc.

And I wrote incorrectly that I use 0.6366 for pi/2, but of course I
mean 2/pi. Now I suppose I ought to try using 1:(\$*2/pi). I might
do that.

Thanks for all your responses.
--
Dieter Britz
0 new messages