Gnuplot: data table type value = 'u' and weird bars in histograms

I previously asked this question. This is a related question.

Using the file test.txt:

-0.1  0  0  JANE
1  1  1  BILL
2  2  1  BILL
1  3  1  BILL
6  4  0  JANE
35 5  0  JANE
9  6  1  BILL
4  7  1  BILL
24 8  1  BILL
28 9  1  BILL
9  10  0  JANE
16 11  1  BILL
4  12  0  JANE
45 13  1  BILL

and gnuplot script:

file='test.txt'
binwidth=10
bin(x,width)=width*floor(x/width)

set table "data_table"

plot file using (bin($1,binwidth)):(1.0) smooth freq,\
file using (1+(bin($2,binwidth))):(1.0) smooth freq

unset table

set boxwidth 1
set logscale y
set yrange[0.01:15]

plot "data_table" index 0 using ($1):($2 == 0 ? 1/0 : $2) with boxes,\
"data_table" index 1 using ($1):($2 == 0 ? 1/0 : $2) with boxes

I get data_table:

# Curve 0 of 2, 7 points
# Curve title: "file using (bin($1,binwidth)):(1.0)"
# x y type
-10  1  i
 0  8  i
 10  1  i
 20  2  i
 30  1  i
 40  1  i
 0  1  u


# Curve 1 of 2, 3 points
# Curve title: "file using (1+(bin($2,binwidth))):(1.0)"
# x y type
 1  10  i
 11  4  i
 1  1  u

In the "help task table" in the Gnuplot shell: "... the R character takes one of three values:" i "if the point is in the active range," o "if it is out of range, or" u "if it is undefined . "

Question 1 . Why data_tabledoes the last row of each index group in matter uand why does the value xseem to be inoperative?

2. . (x = 0, y = 1), . ?

+3
1
  • , undefined u, , . # 1274.

  • Gnuplot . , undefined, gnuplot , y = 1.

    , , u , strcol(3) eq "u":

file='test.txt'
binwidth=10
bin(x,width)=width*floor(x/width)

set table "data_table"

plot file using (bin($1,binwidth)):(1.0) smooth freq,\
file using (1+(bin($2,binwidth))):(1.0) smooth freq

unset table

set boxwidth 1
set logscale y
set yrange[0.01:15]
unset key

plot "data_table" index 0 using ($1):($2 == 0 || strcol(3) eq "u" ? 1/0 : $2) with boxes,\
"data_table" index 1 using ($1):($2 == 0 || strcol(3) eq "u" ? 1/0 : $2) with boxes

enter image description here

+4

Source: https://habr.com/ru/post/1606477/


All Articles