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

3D mesh plotting with a fourth column of data for colouring pm3d

1,069 views
Skip to first unread message

Javiere

unread,
Jul 22, 2015, 1:41:46 PM7/22/15
to
Dear all.

My 3d mesh plotting is currently being colored using gnuplot pm3d. However the pm3d colours should be related to a variable different from the z value.

It is indicated that (in addition to x,y,z) a fourth column of data should be used for gnuplot to read RGB color information (http://www.gnuplotting.org/manpage-gnuplot-4-6/#Q1-1-536).

I only recently started using gnuplot and am further constrained by the fact that gnuplot site is temporarily offline (http://gnuplot.sourceforge.net/demo/).

Can anybody can let me know how to relate number values with colours?

javiere...@gmail.com

unread,
Jul 22, 2015, 2:03:48 PM7/22/15
to
It clear to me the command required to do the plotting:
splot ... using 1:2:3:4 with pm3d lc rgb variable.

I do not know how to relate the 4th column values with RGB colours.

Ethan A Merritt

unread,
Jul 22, 2015, 2:55:40 PM7/22/15
to
javiere...@gmail.com wrote:

> On Wednesday, July 22, 2015 at 12:41:46 PM UTC-5, Javiere wrote:
>> Dear all.
>>
>> My 3d mesh plotting is currently being colored using gnuplot pm3d.
>> However the pm3d colours should be related to a variable different from
>> the z value.
>>
>> It is indicated that (in addition to x,y,z) a fourth column of data
>> should be used for gnuplot to read RGB color information
>> (http://www.gnuplotting.org/manpage-gnuplot-4-6/#Q1-1-536).
>>
>>
>> Can anybody can let me know how to relate number values with colours?
>
> It clear to me the command required to do the plotting:
> splot ... using 1:2:3:4 with pm3d lc rgb variable.
>
> I do not know how to relate the 4th column values with RGB colours.

The 4th column in that case is interpreted as a 24-bit integer
with containing 8-bit color components (integers 0-255)
I.e.

foo = (Red << 16) + (Green << 8) + (Blue)

Gnuplot can read hexadecimal numbers, so one possible format for
the 4th column is

0xffffff # white
0xff0000 # pure red
0x7f007f # half intensity magenta

and so on.

>> I only recently started using gnuplot and am further constrained by the
>> fact that gnuplot site is temporarily offline
>> (http://gnuplot.sourceforge.net/demo/).

Older copy of relevant demo:

http://skuld.bmsc.washington.edu/~merritt/gnuplot/demo_canvas/heatmaps.html

Ethan

Javiere

unread,
Jul 24, 2015, 1:11:26 PM7/24/15
to
Ethan. I appreciate your help.

I have been trying different options and managed to include 3d mesh coloring using a fourth columns including number values using. I am using commands of the form "splot "data.txt" using 1:2:3:6 with lines lt 27"

However I did not find hexadecimal colour representation useful to plot the fading and blending effect of colours of a given palette as can be seen in the demos you sent me. In fact, these graphs use formulas to produce numbers to be translated into corresponding colours of the given palette.

Therefore I decided to work with a fourth column containing number values !?

Worringly, if I try to include a black spot at a particular position on the surface (which i need to do for signaling purposes), the whole surface acquires a colour that corresponds to an extreme of the palette in effect. I assume this is not supported by gnuplot.

Javiere

Ethan A Merritt

unread,
Jul 25, 2015, 1:55:00 AM7/25/15
to
There seems to be some confusion here, maybe on my part, maybe on yours.
The mechanism I suggested is relevant to coloring modes that use RGB
colors. That's what I thought you originally asked about.

It sounds like you have decided to use palette colors instead?
That's fine, but without seeing the script you are using I can't say
what is wrong with the color mapping. Here are some things
to keep in mind.
- The color palette is always defined in the range 0 to 1
- This is mapped to a different numerical range using the
commands "set cbrange [low:high]" or "set auto cb" etc
- If the surface being colored contains a value outside of the
range, it is assigned the color at the extreme of the palette
(0 or 1).
- If you want that extreme value to be separate from the gradient
spanning the rest of the range [0:1] you can define a palette
containing two parts.

Here is an example:

set palette defined (0 "black", 0 "black", 0 "green", 1 "white")
set cbrange [50:100]
splot FOO using 1:2:3:4 with pm3d

This defines a palette that runs smoothly from green to white over the
numerical range 50 to 100. Values greater than 100 are mapped
to white. However values <= 50 are mapped to black rather than green.

I know from past experience that I'm terrible at explaining how the
color palette works, so if the above is unclear it's probably my fault.
Give it another try and look through more of the demos now that
they are back on-line.

Ethan

Javiere

unread,
Jul 28, 2015, 10:15:00 PM7/28/15
to
Ethan

There was confusion on my part. Your explanation IS very clear.
I have now managed to display extreme values in a different colour (black) as you have indicated. My script is now (somehow it requires set pm3d two times)

set cbrange [-2:.7]
set xrange [0:40]
set yrange [0:40]
set palette defined (0 "black", 0 "black", 0 "dark-blue", 1 "white")
set pm3d
set pm3d corners2color c1
splot "terrain.txt" using 1:2:3:7 with lines lt 27

Unfortunately the resulting darkblue-white fading does not have as much contrast as I was getting with "set palette rgbformulae 23,28,3", not even with "Set palette gamma" (but now I am getting the extreme values displayed in black, as was desired).
Perhaps I should explore with "set palette file <filename>" for more contrast in my "terrain" colouring AND extreme valued displayed in black !?

However, my real challenge is to display the image repeatedly through C/C++. For C++ there is #include "gnuplot-iostream.h". For C there are "pipes". However C/C++ - gnuplot communication setting is still a challenge.

I very much appreciate your help.

Javiere
0 new messages