Reputation: 45
After showing some values on top of bars like here. I think thats a good idea. On the other point: Is there is also a way hide some values on the top of bars. Lets say: I have lots of "0", which says nothing in the histogram.
Upvotes: 0
Views: 179
Reputation: 15093
You do not show your specific plot command, so I will assume something similar to the answer you link to. It uses essentially
plot 'data' u 2 with histogram ,\
'' u 0:2:2 with labels font "Helvetica,10" offset -0.9,0.5
You ask how to modify this so that zero values do not produce a label. Here is one possibility. Note that the original answer treats the values in column two as strings for the purpose of "with labels" but we are going to change this to treating them as numbers so that we can test against 0.
filter(col) = (column(col) == 0) ? "" : sprintf("%.1f", column(col))
plot 'data' u 2 with histogram ,\
'' u 0:2:(filter(2)) with labels font "Helvetica,10" offset -0.9,0.5
Upvotes: 1