Color contour plots from "Impossible gnuplot graphs "

  • Follow


Dear all,

I am trying to get the color contour script from

http://www.phyast.pitt.edu/~zov1/gnuplot/html/contour.html

running (see the lower part of this page). While the monochrome script 
with aligned labels works fine the second script produces errors like

if(nr==int(os+w/2) && (d \%2)==0) {a[i]=$1; b[i]=$2; c[i]=$3;}
                          ^ backslash not last character on line

Maybe there is only a tiny syntax error or gawk version clash causing 
this problem.

Furthermore, the implementation of the new script and the handling of 
the new temporary file cont.plt is described ambiguously. It is not 
clear, how to change the call of the .sh script in the gnuplot file.

Did anyone try these scripts (which were very nice if they were working)?

Ingo
0
Reply ingo.thies (51) 4/21/2010 9:03:05 AM

Hi,

Ingo Thies schrieb:
> 
> I am trying to get the color contour script from
> 
> http://www.phyast.pitt.edu/~zov1/gnuplot/html/contour.html
> 
> running (see the lower part of this page). While the monochrome script 
> with aligned labels works fine the second script produces errors like
> 
> if(nr==int(os+w/2) && (d \%2)==0) {a[i]=$1; b[i]=$2; c[i]=$3;}
>                           ^ backslash not last character on line
> 
> Maybe there is only a tiny syntax error 

I haven't used those scripts, but I guess you must just remove the 
backslash to get the modulo operator '%' (also in the following three 
lines).

Christoph
0
Reply Christoph 4/21/2010 10:47:55 AM


On Wed, 21 Apr 2010 11:03:05 +0200, Ingo Thies wrote:

> Dear all,
> 
> I am trying to get the color contour script from
> 
> http://www.phyast.pitt.edu/~zov1/gnuplot/html/contour.html
> 
> running (see the lower part of this page). While the monochrome script
> with aligned labels works fine the second script produces errors like
> 
> if(nr==int(os+w/2) && (d \%2)==0) {a[i]=$1; b[i]=$2; c[i]=$3;}
>                           ^ backslash not last character on line
> 
> Maybe there is only a tiny syntax error or gawk version clash causing
> this problem.
> 
> Furthermore, the implementation of the new script and the handling of
> the new temporary file cont.plt is described ambiguously. It is not
> clear, how to change the call of the .sh script in the gnuplot file.
> 
> Did anyone try these scripts (which were very nice if they were
> working)?
> 
> Ingo
Hi Ingo,
I took a quick look at the scripts.
I got the backslash error message too on the "second twist" example.
(gawk 3.1.6 on Slackware 12.2 with gnuplot 4.4 patchlevel 0-rc1)
To stop the error is simple - remove the backslash before the % sign
on the 4 lines - so (d\%2) becomes (d%2)

I tried all 4 examples with "set term png" after reset in the plt file.
Compared with the examples on the website:
1 - same.
2 - missing values in the white space. Contour lines look OK.
3 - same
4 - Contour lines not coloured - seem to be black.
    The values have bad orientations and different, but wrong, colours.

I don't understand the last line of Zoltan's description:
cont5.sh 2 15 0 > cont.plt

What the heck is cont5.sh?
Example 1 doesn't have a script. The other 3 examples have scripts.
I called them cont1.sh, cont2.sh and cont3.sh.

Good luck,
Peter 
0
Reply geep 4/21/2010 11:03:57 AM

geep wrote:

> I got the backslash error message too on the "second twist" example.
> (gawk 3.1.6 on Slackware 12.2 with gnuplot 4.4 patchlevel 0-rc1)
> To stop the error is simple - remove the backslash before the % sign
> on the 4 lines - so (d\%2) becomes (d%2)

Thanks. I tried similar things and managed to get rid of the error 
messages. However, I don't get any labels, and the contours are all black.

I cannot see any clear instructions how to implement the new script 
cont5.sh. Do I have to call cont5.sh with first paramerer = 2 (to get 
the labels) first, then with parameter = 1 (or 0)? It's all rather 
unclear, there may be a hundreds of possible combinations (and even 
millions, if you count all the possible syntax interpretations)...

> I don't understand the last line of Zoltan's description:
> cont5.sh 2 15 0 > cont.plt
> 
> What the heck is cont5.sh?

I guess it is simply the name for the second shell script (maybe he had 
temporaty versions 2,3,4 but left them out here).

> Example 1 doesn't have a script. The other 3 examples have scripts.
> I called them cont1.sh, cont2.sh and cont3.sh.

??? I cannot find any of these on that page. Do you refer to another 
page (e.g. your own homepage)?


Ingo
0
Reply Ingo 4/21/2010 11:21:15 AM

Hi again,

it seems that I have found a solution that works:

First (after removing the "\" in front of the "%"), change "cont.plt" to 
  "cont.dat" in line 14 of cont4.sh (since the contour data are saved in 
cont.dat; cont.plt makes no sense here).

Then, replace the line

l '<./cont.sh cont.dat 0 15 0'

in the previous gnuplot script by the two lines

l '<./cont5.sh cont.dat 0 15 0'
l '<./cont5.sh cont.dat 2 15 0 > cont.plt'

The first line writes the labels into the memory, the second stores the 
plot command into cont.plt. Finally, remove the entire p(lot) line and 
instead type

load 'cont.plt'

to load the plot command. Maybe it is also possible to do this via awk 
completely, but definitely not the way suggested on that web page. If 
one tries so, then the contour lines are black again.

An enhancement would be to replace the lt (linetype) statements by lc 
(linecolor) or, even more flexible, by ls (linestyle) definitions 
(which, of course, would have provided in the gnuplot script).


Ingo
0
Reply Ingo 4/21/2010 11:40:37 AM

I wrote:

> it seems that I have found a solution that works:

This solution has still bugs. The whitespace in the contour lines is 
gone now and the orientation of the labels is now completely randomly. I 
  think, the whole thing needs a major revision anyway before becoming 
read to use. The uncoloured contours, however, seem to work properly.

Ingo
0
Reply Ingo 4/21/2010 11:45:21 AM

Christoph Bersch wrote:

> I haven't used those scripts, but I guess you must just remove the 
> backslash to get the modulo operator '%' (also in the following three 
> lines).

What exactly is the purpose of the %2 after the d here? I have little 
experience with awk so far, but I guess one could make it working by 
splitting it up in several scripts and by writing the label and plot 
commands into separate files (and loading them into gnuplot by "load 
'label.gp'", "load 'plot.gp'" etc.) instead of creating them inline. 
This would also make it more transparent for debugging.

Ingo
0
Reply Ingo 4/21/2010 11:51:25 AM

Ingo Thies wrote:

> This solution has still bugs. The whitespace in the contour lines is 
> gone now and the orientation of the labels is now completely randomly. I 
>  think, the whole thing needs a major revision anyway before becoming 
> read to use. The uncoloured contours, however, seem to work properly.

OK, now I think we may come to a point of convergence:

Chance "cont.dat" to "cont.tmp" in the "plot" line of cont5.sh to read 
the data from a temporary data file which is essentially cont.dat 
without header and with some points around the label spaces removed. 
Since gnuplot will now try to read this from cont.tmp we must first 
write the modified data file by piping the output of cont5 1... into it.

Now the corresponding line are

l '<./cont5.sh cont.dat 0 15 0 > cont.lbl'
l '<./cont5.sh cont.dat 1 15 0 > cont.tmp'
l '<./cont5.sh cont.dat 2 15 0 > cont.plt'

load 'cont.lbl'
load 'cont.plt'

The rest will - hopefully - be just the replacement of the "lt" by "ls" 
and definition of the linestyles somewhere above in the gp script.

PS the misaligned labels were simply due to a missing division by pi 
(approx. 3.14 in the script).

Ingo
0
Reply Ingo 4/21/2010 12:38:12 PM

On Wed, 21 Apr 2010 13:21:15 +0200, Ingo Thies wrote:

>> Example 1 doesn't have a script. The other 3 examples have scripts. I
>> called them cont1.sh, cont2.sh and cont3.sh.

They are just the names I gave them.
Maybe Zoltan will spot this discussion and intervene.
It would be nice if his webpage referred to the scripts by specific names
like cont1.sh, cont2.sh and cont3.sh etc.
Cheers,
Peter

> 
> ??? I cannot find any of these on that page. Do you refer to another
> page (e.g. your own homepage)?
> 
> 
> Ingo

0
Reply geep 4/21/2010 6:14:11 PM

Hi,

> OK, now I think we may come to a point of convergence:

FYI, there is a new version of that script working around the need for 
gawk scripts. It's all done in gnuplot but relies on a rather new build 
of it.

http://gnuplot-tricks.blogspot.com/2010/02/map-inline-function-and-macro.html

Steffen

0
Reply Steffen 4/22/2010 6:42:10 PM

Am 2010-04-22 20:42, schrieb Steffen:

> FYI, there is a new version of that script working around the need for
> gawk scripts. It's all done in gnuplot but relies on a rather new build
> of it.
>
> http://gnuplot-tricks.blogspot.com/2010/02/map-inline-function-and-macro.html

As far as I can see, this script isn't new at all but just equivalent to 
the first script on the original page that doesn't align the labels and 
only produces monochrome contours. That one is also done in gnuplot 
alone (but maybe the new one is more elegant by making use of new 
gnuplot features).

-- 
Gruß,
       Ingo
0
Reply Ingo 4/22/2010 6:59:48 PM

I wrote:

> As far as I can see, this script isn't new at all but just equivalent to 
> the first script on the original page that doesn't align the labels and 
> only produces monochrome contours. That one is also done in gnuplot 
> alone (but maybe the new one is more elegant by making use of new 
> gnuplot features).

Addition: But it is easy, to enable at least colored lines and labels by 
applying an additional incremented index and use the color of the 
according linetype (or, not yet tested, user-defined linestyle) to it 
and to the textcolor.

Aligned labels maybe possible too, but this may be more tricky. And not 
really required, unless one want to create a topographic map.

Ingo
0
Reply Ingo 4/23/2010 7:55:22 AM

11 Replies
372 Views

(page loaded in 0.953 seconds)

Similiar Articles:













7/20/2012 9:54:23 AM


Reply: