| 
      
      
      From: Ethan M. <eam...@gm...> - 2024-05-01 21:12:22
      
     | 
| On Wednesday, 1 May 2024 13:05:40 PDT Frank Steiner wrote:
 
> I'm trying to plot some csv files and have problem with coloring the
> bars with a helper function if the function returns only one value
> instead of different ones.
"set palette" defines a span of colors that so far as the palette itself is concerned
run from 0 to 1.   0 = first color;  1 = last color.
The program then maps that onto the color axis range (cb).
That is to say,  palette 0 is mapped to cb[min] and palette 1 is mapped to cb[max].
By default the cb[min:max] range is auto-scaled to the z range of the plot content.
In most 3D plotting modes this is reasonable, although not necessarily what you
want if the palette coloring is supposed to represent some pre-determined
absolute scale.  In 2D plots the z coordinate may or may not be defined at all.
Your plot command duplicates the y value as a z value, so by default
the cbrange will autoscale to the range on y.   If there is only one y value
then it collapses as you have seen.
Long story short:   Set the cbrange manually to whatever you think appropriate.
If you only expect values between 1 and 3 on y then do "set cbrange [0:3]".
    Ethan
> Using the files "test.csv" with content
> 1 1
> 2 2
> 3 3
> 
> In gnuplot 6.0 I call:
> gnuplot> file="test.csv"
> gnuplot> set yrange [0:3]
> gnuplot> set palette defined (1  'red', 2  'green', 3  'blue')
> gnuplot> color(x)=x
> gnuplot> plot file using 1:2:(color($2)) with boxes fill pattern 2 lc palette
> 
> I get three bars with colors red, green and blue from left to right.
> 
> But when I change test.csv so that the values in the second column
> are all "1" I get all three bars in green and the warning
> "Warning: empty cb range [1:1], adjusting to [1.98:2.02]"
> 
> Same when the second colums contains only 2 or only 3: the warning
> message changes w.r.t. to the numbers (e.g. range [2:2] etc.) but
> the bars are always green.
> 
> Thus, when I have a csv file that causes my (more complex) color function
> to return only one value, then the colors of the bars are wrong. Like a csv
> file with only error values would show green (="ok") bars instead of
> red (="error") ones.
> 
> Is that a bug or is my understanding of "lc palette" wrong?
> 
> Thanks!
> cu,
> Frank
> 
> 
 |