0
votes

Is it possible, that gnuplot does not plot areas, where the z-value is zero?

If I have a grid like:

0  0  24 25
0  23 24 25
23 23 24 0
24 24 0  0

I would like to only see the "lane", but now gnuplot tries to plot some (mean?) values, where the zeros are. As a file, I am taking some measurement-values. My config-file for the plot:

set grid lt 2 lw 1
set surface
set parametric
set xtics
set ytics
set style data lines
set dgrid3d 80,80,3
splot file

The datafile for this grid would be:

1 3 24
1 4 25
2 2 23 
2 3 24
2 4 25
3 1 23
3 2 23
3 3 24
4 1 24
4 2 24 

So, no zeros are in the datafile.

1

1 Answers

1
votes

I'm having a difficult time understanding exactly what you want to do, but hopefully the following will be helpful.

Say we have a datafile (test.dat):

NaN NaN NaN NaN NaN NaN NaN 100 200
NaN NaN NaN NaN NaN NaN 100 200 100
NaN NaN NaN NaN NaN 100 200 100 NaN
NaN NaN NaN NaN 100 200 100 NaN NaN
NaN NaN NaN 100 200 100 NaN NaN NaN
NaN NaN 100 200 100 NaN NaN NaN NaN
NaN 100 200 100 NaN NaN NaN NaN NaN
100 200 100 NaN NaN NaN NaN NaN NaN
200 100 NaN NaN NaN NaN NaN NaN NaN

We can plot this datafile using:

set datafile missing 'NaN'
set style data lines
splot 'test.dat' matrix  #matrix allows our datafile to look like your first data grid

If I understand what you want correctly, you can't accomplish it without putting your data into a "grid" format (either using matrix or with "scan separators" (see below). dgrid3d won't work here since it doesn't know how to designate pieces of the data as missing. If you don't want to use matrix format, you can do:

#Note the blank spaces!
#Each block doesn't have to have the same number of lines
#but the resulting plot looks nicest if it does.
#for lines that you want to make blank, use some character to
#mark that data as missing.  (I used 'NaN' above, but you can
#use anything you want.  sometimes I use '?' too).
x1 y1 num
x1 y2 num
x1 y3 num
...

x2 y1 num
x2 y2 num
x2 y3 num
...               

...

xN y1 num
xN y2 num
xN y3 num
...

As a concrete example: for your grid:

1 1 ?
1 2 ?
1 3 24
1 4 25

2 1 ?
2 2 23 
2 3 24
2 4 25

3 1 23
3 2 23
3 3 24
3 4 ?

4 1 24
4 2 24 
4 3 ?
4 4 ?

And then:

set datafile missing '?'
set style data lines
splot 'my_data.txt'  #Not matrix this time.

Of course, with data at this resolution, the plot still may not look the way you want it, but hopefully that demonstrates the point.

EDIT

If you can get your datafile into the format that you show at the top of your post, you have a few (additional) options (without messing with the zeros):

set datafile missing '0'  #This just has the effect of removing the 0 values from the plot
splot 'myfile.txt' matrix

Or:

set zrange [0.5:]   #This also removes the 0 values, but alters the z-range.
splot 'myfile.txt' matrix