7

I am struggling with the following problem. I have a file with three columns, the x-coord, y-coord and count; think of it as of a sparse histogram, where a point is outputted only when count > 0.

I am trying to visualize it using GNUPLOT via

set palette defined (0 'white', 0.25 'blue', 0.5 'green', 0.75 'yellow', 1 'red')
plot 'file' w p pt 7 palette t ''

which works just fine. Now, I would like to have a logarithmic color box, that is so that the colors are mapped to log(count). I could trick it through u 1:2:(log($3)), but the scale on the color box would be off.

Using set log cb actually gives me an error: GNUPLOT complains that the data is negative, which it is not, I have hand-checked the offending file. This is the error I get from a cut-down version of the file,

gnuplot> set logscale cb
gnuplot> plot 'data.dat' w p pt 7 palette
Warning: empty x range [-0.226728:-0.226728], adjusting to [-0.228995:-0.22446]
         color axis has cb coord of -3.20125; must be above 0 for log scale!

The data file is actually very small:

-2.2672752051521861e-01 -9.0322580645161288e-01  1.2583021897450098e-03
-2.2672752051521861e-01 -8.3870967741935487e-01  1.2583021897450098e-02
-2.2672752051521861e-01 -7.7419354838709675e-01  6.2915109487250492e-03
-2.2672752051521861e-01 -7.0967741935483875e-01  1.0066417517960079e-02
-2.2672752051521861e-01 -6.4516129032258063e-01  1.0066417517960079e-02
-2.2672752051521861e-01 -5.8064516129032262e-01  3.7749065692350295e-03
-2.2672752051521861e-01 -5.1612903225806450e-01  6.2915109487250492e-03
-2.2672752051521861e-01 -4.5161290322580649e-01  2.5166043794900197e-03
-2.2672752051521861e-01 -3.8709677419354838e-01  4.4040576641075340e-03
-2.2672752051521861e-01 -3.2258064516129037e-01  2.5166043794900197e-03
-2.2672752051521861e-01 -2.5806451612903225e-01  1.2583021897450098e-03
-2.2672752051521861e-01 -1.9354838709677424e-01  3.1457554743625246e-03
-2.2672752051521861e-01 -1.2903225806451613e-01  6.2915109487250492e-04
-2.2672752051521861e-01 -6.4516129032258118e-02  1.2583021897450098e-03
-2.2672752051521861e-01  0.0000000000000000e+00  4.4040576641075340e-03
-2.2672752051521861e-01  6.4516129032258007e-02  1.2583021897450098e-03
-2.2672752051521861e-01  1.2903225806451601e-01  1.8874532846175148e-03
-2.2672752051521861e-01  1.9354838709677424e-01  3.1457554743625246e-03
-2.2672752051521861e-01  3.2258064516129026e-01  1.2583021897450098e-03
-2.2672752051521861e-01  3.8709677419354827e-01  2.5166043794900197e-03
-2.2672752051521861e-01  4.5161290322580649e-01  3.7749065692350295e-03
-2.2672752051521861e-01  5.1612903225806450e-01  5.6623598538525447e-03
-2.2672752051521861e-01  5.8064516129032251e-01  6.2915109487250492e-03
-2.2672752051521861e-01  6.4516129032258052e-01  6.9206620435975537e-03

What's wrong?

1 Answers1

9

That seems to be a bug concerning the autoscaling of the logarithmic color axis. Setting an explicit cbrange works fine with 4.6.4. In that case you can also use the stats command to extract minimum an maximum values.

The following script works:

set palette defined (0 'white', 0.25 'blue', 0.5 'green', 0.75 'yellow', 1 'red')
stats 'file' using 3
set logscale cb
set cbrange[STATS_min:STATS_max]
plot 'file' w p pt 7 palette t ''

The result with 4.6.4 is:

enter image description here

Christoph
  • 47,569
  • 8
  • 87
  • 187