pcolor and "interp"
Ben Abbott
bpabbott at mac.com
Wed Sep 24 16:27:57 CDT 2008
On Wednesday, September 24, 2008, at 03:58PM, "Kai Habel" <kai.habel at gmx.de> wrote:
>Ben Abbott schrieb:
>>
>> On Sep 24, 2008, at 1:38 AM, Kai Habel wrote:
>>
>>> Ben Abbott schrieb:
>>>> was Subject: Re: [changeset] clarification to pcolor doc-string
>>>>
>>>> I've not yet attempted to change __go_draw_axes__.m, but I have been
>>>> able to determine what needs to be changed in the gnuplot stream for
>>>> the interpolation to work.
>>>>
>>>> One qualifier; the result is not equivalent to Matlab, which uses a
>>>> bilinear interpolation, enabled by segmenting each rectangular cell
>>>> into a pair of triangles.
>>>>
>>>> In any event, using gnuplot 4 lines of the stream need to be
>>>> modified. I'll use the short example supplied by jwe to demonstrate.
>>>>
>>>> pcolor (peaks ());
>>>> shading interp
>>>> drawnow ("x11", "/dev/null", false, "debug.gp")
>>>>
>>>> The 4 lines in debug.gp which require modification are listed below.
>>>>
>>>> < 42 set pm3d explicit at s corners2color c3;
>>>>> 42 set pm3d explicit at s interpolate 2, 2 corners2color c3;
>>>> < 43 set pm3d explicit at s depthorder corners2color c3;
>>>>> 43 #set pm3d explicit at s depthorder corners2color c3;
>>>> 44 set pm3d explicit;
>>>> 45 unset hidden3d;
>>>> 46 set xrange [-3.000000000000000e+00:3.000000000000000e+00]
>>>> noreverse;
>>>> 47 set yrange [-3.000000000000000e+00:3.000000000000000e+00]
>>>> noreverse;
>>>> < 48 set zrange [-1.000000000000000e+00:1.000000000000000e+00]
>>>> noreverse;
>>>>> 48 #set zrange [-1.000000000000000e+00:1.000000000000000e+00]
>>>> noreverse;
>>>> [...]
>>>> < 62 splot "-" using ($1):($2):($3):($4) title "" with pm3d
>>>> linestyle 1 \
>>>>> 62 splot "-" using ($1):($2):($4) title "" with pm3d linestyle 1 \
>>>>
>>>> After making the changes, the result may be rendered by
>>>>
>>>> gnuplot -persist debug.gp
>>>>
>>>> The part, "interpolate 2, 2", increases the <steps in scan> and <steps
>>>> between scans>, respectively. In this instance I've increase each from
>>>> 1 to 2. The general format for this is;
>>>>
>>>> set pm3d interpolate <steps in scan>,<steps between scans>
>>>>
>>>> I am not yet prepared to explain way the changes are needed for the
>>>> zrange or why ($3) needed to be removed. but I need to make each of
>>>> these changes to produce a proper result. I'm running gnuplot 4.2.3.
>>>>
>>>> If some one is running a version of gnuplot more recent than v4.2.3,
>>>> I'd be interested is how it handles the result.
>>>>
>>>> I'll look into __go_draw_axes__.m tomorrow, but if anyone has some
>>>> functional understanding of the details ... please jump in.
>>>>
>>>> Ben
>>>>
>>> I see the same effect with the recently released gnuplot 4.2.4. If you
>>> look at __go_draw_axes__.m you find some remains from my attempt to
>>> implement the interp mode. Look for "Interp_str" which is currently set
>>> to an empty string.
>>>
>>> Kai
>>
>> I saw that and wondered who had worked on it.
>>
>> As the pcolor has the setting below
>>
>> set view map;
>>
>> I was thinking of checking for facecolor==interp, view==map and
>> object==surface to determine when these changes are appropriate.
>>
>> Is there a more proper way to determine when to (1) set "interp_str",
>> (2) drop "($3)", and (3) not specify "zrange"?
>>
>> Ben
>>
>>
>I have played a bit with gnuplot and it seems the interpolation works
>only for zvalues (3rd column) and not cvalues (4th column). Since we set
>z=0 for pcolor the interpolation does not work here (?). And if you drop
>the 3rd column than ($4) is interpreted as z-value. This look o.k. if
>you view it from above but if you change the view you can see that z!=0.
>So, I see no easy solution.
>
>Kai
I agree. There was some mention of a patch to gnuplot which addresses the interpolation of colors across a 3D patch where the colors are independent of the z-coordinate. I have no idea as to the whether or not the patch mentioned resolves our current problem, but see no harm in assuming it will.
For that reason, I'm inclined to assign an appropriate value to "interp_str" (we might set it to null for gnuplot v 4.3 or below).
I'm also inclined to consider support interpolation of colors for surface objects drawn with "view map" and all(z==0), In the event either of these requirements are not met we can fall back to the current state.
As I still haven't dug deep into the code, I'm not certain as to how much work is needed to implement such a scheme in __go_draw_axes__.m ... nor am I happy about the difficulties of code maintenance this might eventually produce.
Thoughts?
Ben
More information about the Bug-octave
mailing list