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.
Asked
Active
Viewed 170 times
1 Answers
1
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

Ethan
- 13,715
- 2
- 12
- 21
-
The examples are kind from the post, which I shared. – Gaem Oct 13 '18 at 05:58
-
Thanks for the answer. If you wanna use this without floating point number, then use this code: `filter(col) = (column(col) == 0) ? "" : sprintf("%.0f", column(col))` – Gaem Oct 13 '18 at 06:18