[manual] suggested addition to pcolor description

Ben Abbott bpabbott at mac.com
Tue Jan 20 19:10:20 CST 2009


On Jan 20, 2009, at 1:15 PM, Kai Habel wrote:

> John W. Eaton schrieb:
>> On 20-Jan-2009, Ben Abbott wrote:
>>
>> | On caveat is that gnuplot's method of interpolation is different
>> | than that of Matlab's. As Francesco points out the commercial
>> | variant splits rectangles into a pair of triangles and performs a
>> | linear interpolation of the color across the triangle. Although I  
>> do
>> | not know what algorithm is used, gnuplot does not work the same  
>> way.
>>
>> Is this something that Octave should do, rather than relying on
>> gnuplot?  If so, where does this code belong?  Maybe we should  
>> provide
>> a function (accessible from C++ and the scripting language?) that  
>> does
>> the interpolation, so that all backends can do things consistently.
>>
> No,
>
> I would leave this to the particular backend.
>
> In 2007, I noticed that even matlab behaves differently depending on
> platform (linux, windows) and renderer (OpenGL, ...) when plotting
> polygons. But I have not verified if its still true. Also, OpenGL does
> this interpolation with hardware acceleration, so we would waste a lot
> of graphic performance in this case.
>
> Kai

I studied the situation more closely and noticed that gnuplot appears  
(to me) to interpolate colors by increasing the density of the facets  
by four. The color of facets appear to snap to the nearest color in  
the colormap.

If anyone is running a copy of gnuplot with the patch for  
interpolating color as a 4th dimension, you can examine this by

	[x,y,z] = peaks(10);
	pcolor([x,y,z])
	shading interp
	shading faceted

I've produced png's illustrating the result for both Octave+gnuplot  
and the "other" program.

A simpler example is

	pcolor([1 2; 3 3])
	shading interp

Plots can be seen at the link below.

	http://www.picturehosting.com/gallery.php?u=bpabbott&g=pcolor

The "other guy" segments the rectangular mesh into triangles and then  
uses linear interpolation to the nearest color in the colormap (notice  
the bands in their result). As I have no knowledge of OpenGL, can  
someone tell me/us; is this something OpenGL does on its own?

In any event, I agree with Kai. The backend should handle this.  
Regarding Octave's gnuplot backend, I don't see anything that Octave  
should do differently.

I've copied Petr in the event my inference regarding the gnuplot  
implementation is in error ... or in the event he has some insight as  
to the possibility of modifying the behavior of gnuplot.

Ben





More information about the Bug-octave mailing list