When plotting a surface with hidden3d I get the top view of the surface in green, the bottom view in blue, this can also be found in the examples, mostly the other way round, top view blue, bottom view green (why is that ?).
I managed to change the color of the lines but only to the same for top and bottom with
splot '-' matrix with lines linecolor 'black'
How do I change green and blue to my desired valus? I searched a lot and found some hints, but can't get it working. Must have something to do with line type or set style ??
Thanks for any help
Update: source and picture
I control gnuplot from a C++ program through a pipe. Here are the corresponding control commands:
fprintf (gnuplotPipe, "set terminal windows\n");
fprintf (gnuplotPipe, "set hidden3d\n");
fprintf (gnuplotPipe, "set title '3D Surface'\n");
fprintf (gnuplotPipe, "set zrange [0:100]\n");
fprintf (gnuplotPipe, "set xyplane at 0\n");
fprintf (gnuplotPipe, "unset key\n"); // hide the key
// fprintf (gnuplotPipe, "splot '-' nonuniform matrix using 1:2:3 with lines linecolor 'black'\n");
fprintf (gnuplotPipe, "splot '-' nonuniform matrix using 1:2:3 with lines\n");
fprintf (gnuplotPipe, "\n");
After that I send this array that is a gnuplot nonunioform matrix:
constexpr int32_t surface [y_size + 1][x_size + 1] = {
{ 20, 0, 216, 431, 647, 862, 1078, 1293, 1509, 1724, 1940, 2155, 2371, 2586, 2802, 3017, 3233, 3448, 3664, 3879, 4095},
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
{ 0, 89, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 89, 89},
{ 216, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 89, 89, 89},
{ 431, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89},
{ 647, 90, 90, 90, 90, 90, 90, 90, 89, 89, 89, 88, 88, 88, 87, 87, 87, 87, 86, 86, 87},
{ 862, 90, 90, 90, 90, 90, 89, 89, 88, 88, 87, 86, 85, 85, 84, 84, 83, 83, 82, 82, 82},
{1078, 90, 90, 90, 90, 89, 89, 88, 87, 86, 84, 83, 81, 80, 79, 78, 77, 76, 76, 76, 76},
{1293, 90, 90, 90, 90, 89, 88, 87, 85, 83, 81, 79, 76, 74, 72, 70, 68, 67, 67, 67, 67},
{1509, 90, 90, 89, 89, 88, 87, 85, 83, 81, 77, 74, 70, 66, 63, 61, 59, 58, 58, 59, 60},
{1724, 90, 90, 90, 89, 88, 86, 84, 82, 78, 74, 70, 65, 60, 56, 51, 47, 45, 47, 50, 54},
{1940, 89, 89, 89, 89, 87, 86, 83, 80, 76, 71, 66, 61, 56, 49, 38, 17, 24, 39, 47, 52},
{2155, 89, 89, 89, 89, 87, 85, 83, 79, 75, 70, 65, 60, 55, 48, 41, 38, 42, 48, 52, 56},
{2371, 89, 89, 89, 88, 87, 85, 82, 79, 74, 70, 65, 60, 56, 53, 51, 51, 53, 56, 58, 61},
{2586, 89, 89, 89, 88, 87, 85, 82, 79, 75, 70, 66, 63, 60, 58, 58, 58, 59, 61, 63, 65},
{2802, 89, 89, 89, 88, 86, 84, 82, 79, 75, 71, 68, 65, 63, 62, 62, 63, 64, 65, 67, 68},
{3017, 89, 89, 89, 88, 86, 84, 82, 79, 76, 73, 70, 68, 67, 66, 66, 67, 68, 69, 70, 72},
{3233, 89, 89, 89, 88, 86, 84, 82, 80, 77, 74, 72, 70, 69, 69, 69, 70, 71, 72, 73, 74},
{3448, 89, 89, 89, 88, 86, 85, 83, 80, 78, 76, 74, 73, 72, 72, 72, 73, 74, 74, 76, 76},
{3664, 89, 89, 88, 88, 86, 85, 83, 81, 79, 77, 75, 75, 74, 74, 74, 75, 76, 77, 77, 78},
{3879, 89, 89, 89, 88, 86, 85, 83, 81, 80, 78, 77, 76, 76, 76, 76, 77, 78, 78, 79, 80},
{4095, 89, 89, 88, 88, 86, 85, 83, 82, 80, 79, 78, 78, 78, 78, 78, 78, 79, 80, 80, 81},
};
With the line that includes "with lines linecolor 'black'" both sides are black. I would like something like the top view blue and the bottom view light grey.
The colors look to me like the gnuplot default colors 1 (bottom) and 2 (top).
So, change these linetypes to the desired color (check help linetype
).
Data: SO77638353.dat
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
20, 0, 216, 431, 647, 862, 1078, 1293, 1509, 1724, 1940, 2155, 2371, 2586, 2802, 3017, 3233, 3448, 3664, 3879, 4095
0, 89, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 89, 89
216, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 89, 89, 89
431, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89
647, 90, 90, 90, 90, 90, 90, 90, 89, 89, 89, 88, 88, 88, 87, 87, 87, 87, 86, 86, 87
862, 90, 90, 90, 90, 90, 89, 89, 88, 88, 87, 86, 85, 85, 84, 84, 83, 83, 82, 82, 82
1078, 90, 90, 90, 90, 89, 89, 88, 87, 86, 84, 83, 81, 80, 79, 78, 77, 76, 76, 76, 76
1293, 90, 90, 90, 90, 89, 88, 87, 85, 83, 81, 79, 76, 74, 72, 70, 68, 67, 67, 67, 67
1509, 90, 90, 89, 89, 88, 87, 85, 83, 81, 77, 74, 70, 66, 63, 61, 59, 58, 58, 59, 60
1724, 90, 90, 90, 89, 88, 86, 84, 82, 78, 74, 70, 65, 60, 56, 51, 47, 45, 47, 50, 54
1940, 89, 89, 89, 89, 87, 86, 83, 80, 76, 71, 66, 61, 56, 49, 38, 17, 24, 39, 47, 52
2155, 89, 89, 89, 89, 87, 85, 83, 79, 75, 70, 65, 60, 55, 48, 41, 38, 42, 48, 52, 56
2371, 89, 89, 89, 88, 87, 85, 82, 79, 74, 70, 65, 60, 56, 53, 51, 51, 53, 56, 58, 61
2586, 89, 89, 89, 88, 87, 85, 82, 79, 75, 70, 66, 63, 60, 58, 58, 58, 59, 61, 63, 65
2802, 89, 89, 89, 88, 86, 84, 82, 79, 75, 71, 68, 65, 63, 62, 62, 63, 64, 65, 67, 68
3017, 89, 89, 89, 88, 86, 84, 82, 79, 76, 73, 70, 68, 67, 66, 66, 67, 68, 69, 70, 72
3233, 89, 89, 89, 88, 86, 84, 82, 80, 77, 74, 72, 70, 69, 69, 69, 70, 71, 72, 73, 74
3448, 89, 89, 89, 88, 86, 85, 83, 80, 78, 76, 74, 73, 72, 72, 72, 73, 74, 74, 76, 76
3664, 89, 89, 88, 88, 86, 85, 83, 81, 79, 77, 75, 75, 74, 74, 74, 75, 76, 77, 77, 78
3879, 89, 89, 89, 88, 86, 85, 83, 81, 80, 78, 77, 76, 76, 76, 76, 77, 78, 78, 79, 80
4095, 89, 89, 88, 88, 86, 85, 83, 82, 80, 79, 78, 78, 78, 78, 78, 78, 79, 80, 80, 81
Script:
### change line color in splot
reset session
FILE = "SO77638353.dat"
set hidden3d
set linetype 1 lc "grey"
set linetype 2 lc "blue"
splot FILE nonuniform matrix u 1:2:3 w l
### end of script
Result: