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

Maps of gridded data

1,245 views
Skip to first unread message

Peter Weilbacher

unread,
Jul 31, 2008, 6:08:52 AM7/31/08
to
I am trying to plot a velocity field that is sampled at on a 2D grid at
regular intervals. As these intervals correspond to pixels they should not
overlap but still give a contiguous region in the plot. To accomplish that,
I replot often, changing the pointsize with every plot, until the size
approximately matches the distance between the points.

Example script (for gnuplot Version 4.2 patchlevel 3):
set title "Velocity [km/s]"
set palette defined ( 0 "dark-violet", 1 "dark-blue", 4 "green", 6 "yellow", 8 "orange", 9 "red", 10 "dark-red")
set view map
set cbrange [11730:12040]
# good ps value for x11 terminal
splot "goodvelocities.dat" u 1:2:10:10 t "+" w p ps 1.0 pt 5 pal
set term post enh color
set output "test.ps"
# good ps value for PS
splot "goodvelocities.dat" u 1:2:10:10 t "+" w p ps 0.5 pt 5 pal
set output

This is really cumbersome and I need to find out different pointsizes
depending on the output terminal as you can see above. There is probably
a much better way, but looking through the plot styles I didn't find it.
So I'm grateful for any hints,
Peter.

mer...@chauvet.bmsc.washington.edu

unread,
Jul 31, 2008, 11:51:26 AM7/31/08
to
In article <48918F34...@gaston.Weilbacher.org>,

Peter Weilbacher <news...@weilbacher.org> wrote:
>I am trying to plot a velocity field that is sampled at on a 2D grid at
>regular intervals. As these intervals correspond to pixels they should not
>overlap but still give a contiguous region in the plot. To accomplish that,
>I replot often, changing the pointsize with every plot, until the size
>approximately matches the distance between the points.

This sounds to be exactly with the "with image" style was created for.
One pixel per data point, scaled to fit an arbitrary region on the plot.
You have a choice between using a palette-based pixel coloring from a
single scalar value or a full R/G/B color generated externally.


>
>Example script (for gnuplot Version 4.2 patchlevel 3):
> set title "Velocity [km/s]"
> set palette defined ( 0 "dark-violet", 1 "dark-blue", 4 "green", 6 "yellow", 8 "orange", 9 "red", 10 "dark-red")
> set view map
> set cbrange [11730:12040]
> # good ps value for x11 terminal
> splot "goodvelocities.dat" u 1:2:10:10 t "+" w p ps 1.0 pt 5 pal
> set term post enh color
> set output "test.ps"
> # good ps value for PS
> splot "goodvelocities.dat" u 1:2:10:10 t "+" w p ps 0.5 pt 5 pal
> set output
>
>This is really cumbersome and I need to find out different pointsizes
>depending on the output terminal as you can see above. There is probably
>a much better way, but looking through the plot styles I didn't find it.
>So I'm grateful for any hints,
> Peter.


--
Ethan A Merritt

Peter Weilbacher

unread,
Jul 31, 2008, 1:19:33 PM7/31/08
to
On 31.07.2008 17:51, mer...@chauvet.bmsc.washington.edu wrote:
> In article <48918F34...@gaston.Weilbacher.org>,
> Peter Weilbacher <news...@weilbacher.org> wrote:
>>I am trying to plot a velocity field that is sampled at on a 2D grid at
>>regular intervals. As these intervals correspond to pixels they should not
>>overlap but still give a contiguous region in the plot. To accomplish that,
>>I replot often, changing the pointsize with every plot, until the size
>>approximately matches the distance between the points.
>
> This sounds to be exactly with the "with image" style was created for.
> One pixel per data point, scaled to fit an arbitrary region on the plot.
> You have a choice between using a palette-based pixel coloring from a
> single scalar value or a full R/G/B color generated externally.

Yes, thanks, that seems to work. Indeed now I remember that I tried it
some months (?) ago and had not gotten it to work. I think that's because
my data doesn't fully fill a rectangular area, so I now padded it with
dummy values.

That mode gives some cryptic error messages, so a lot of trial and error
is involved. At least I didn't understand what
GNUPLOT (plot_image): Visible pixel grid has a scan line longer than previous scan lines.
is supposed to mean...

Cheers,
Peter.

mer...@chauvet.bmsc.washington.edu

unread,
Jul 31, 2008, 1:55:18 PM7/31/08
to
In article <4891F42...@gaston.Weilbacher.org>,

Peter Weilbacher <news...@weilbacher.org> wrote:
>On 31.07.2008 17:51, mer...@chauvet.bmsc.washington.edu wrote:
>> In article <48918F34...@gaston.Weilbacher.org>,
>> Peter Weilbacher <news...@weilbacher.org> wrote:
>>>I am trying to plot a velocity field that is sampled at on a 2D grid at
>>>regular intervals. As these intervals correspond to pixels they should not
>>>overlap but still give a contiguous region in the plot. To accomplish that,
>>>I replot often, changing the pointsize with every plot, until the size
>>>approximately matches the distance between the points.
>>
>> This sounds to be exactly what the "with image" style was created for.

>> One pixel per data point, scaled to fit an arbitrary region on the plot.
>> You have a choice between using a palette-based pixel coloring from a
>> single scalar value or a full R/G/B color generated externally.
>
>Yes, thanks, that seems to work. Indeed now I remember that I tried it
>some months (?) ago and had not gotten it to work. I think that's because
>my data doesn't fully fill a rectangular area, so I now padded it with
>dummy values.
>
>That mode gives some cryptic error messages, so a lot of trial and error
>is involved. At least I didn't understand what
> GNUPLOT (plot_image): Visible pixel grid has a scan line longer than previous scan lines.
>is supposed to mean...

That is indeed pretty cryptic.
The error message is from a part of the code that tries to optimize image
rendering, but is known to be fragile. Hence the "EXPERIMENTAL" label attached
to image mode. But there is a non-optimized code path that should be more
robust, although less efficient.

Could you please try adding the keyword "failsafe" to the plot command?
E.g.:
plot 'foo' ... with image failsafe

If that works, then I think your problem is related to known issues.
If it doesn't work, please report what error message or output you get.

--
Ethan A Merritt

Peter Weilbacher

unread,
Aug 1, 2008, 5:17:22 AM8/1/08
to

No, it want's a ';' between image and failsafe, I guess that means this is
not supported in 4.2.3. Will try to update to the CVS version one of these
days and retry.

Peter.

Peter Weilbacher

unread,
Aug 8, 2008, 1:10:06 PM8/8/08
to
On 31.07.2008 19:55, mer...@chauvet.bmsc.washington.edu wrote:

Now there was finally a time where me trying and CVS being accessible
coincided and I compiled the CVS version. ;-)

In the meantime I'm trying to plot slightly different data and haven't gotten
the above message any more. Now I instead get
GNUPLOT (plot_image): Number of pixels cannot be factored into integers
matching grid. N = 7 K = 2
Yes, I guess it's not easy to see from this
plot [0.5:10.5][0.5:10.5] "-" w image
9 1 1755.42
9 2 1688.34
1 3 698.37
3 5 173.087
4 5 1583.47
4 6 1491.55
6 6 1565.41
EOF
that this is a 10x10 grid with lots of missing pixels. Failsafe of course
doesn't help there.

I also sometimes get rhomboids instead of rectangular elements, as in
http://temp.weilbacher.org/test_image2.gp (without failsafe)
http://temp.weilbacher.org/test_image2.png
http://temp.weilbacher.org/test_image3.gp (with failsafe)
http://temp.weilbacher.org/test_image3.png

I guess I can do what I want with rgbimage and transparency but then I have
to make the palette/color computation outside gnuplot.

Peter.

Peter Weilbacher

unread,
Aug 8, 2008, 1:19:48 PM8/8/08
to
On 08.08.2008 19:10, Peter Weilbacher wrote:

> I guess I can do what I want with rgbimage and transparency but then I have
> to make the palette/color computation outside gnuplot.

Hah! The other (better) option is to redefine the palette to include
a background color as the very lowest point that is like transparent to
the output medium (like white for something I want to plot to PS and print).
And set the invalid data points to something below the cbrange, instead of
the usual 1/0 or INDEF.

The rainbox-like palette that I was using is


set palette defined ( 0 "dark-violet", 1 "dark-blue", 4 "green",
6 "yellow", 8 "orange", 9 "red", 10 "dark-red")

but now I have set it to
set palette defined ( 0 "white", 0.00001 "dark-violet", 1 "dark-blue",


4 "green", 6 "yellow", 8 "orange", 9 "red", 10 "dark-red")

That still leaves a small bar of white on the edge of the displayed
colorbar but I think I can live with that. :-)

Cheers,
Peter.

0 new messages