Reputation: 177
In Gnuplot, I am using a bar chart, but not all data points have values. In those places, I want to replace the bar with a vertical text saying "Cannot Serve". How do I do it?
Upvotes: 0
Views: 281
Reputation: 7627
Assuming you have labels to denote missing data, for instance the following data file where missing data are signaled by "NaN":
0 2.3
1 3.1
2 NaN
3 6.1
4 0.5
5 NaN
6 NaN
7 4.9
8 7.0
9 NaN
you can do conditional plotting such that when gnuplot encounters "NaN" it prints a "Missing data" message:
set style fill solid
set boxwidth 0.9
set xrange [-1:10]
plot "data" u ($1):($2) with boxes not, \
"" u ($1):(stringcolumn(2) eq "NaN" ? 1. : 1/0):("Missing data") \
w labels rotate by 90 not
Note that I centered the "Missing data" labels at y = 1. You'll need to adapt that to your needs.
If, instead, your data is just missing:
0 2.3
1 3.1
2
3 6.1
4 0.5
5
6
7 4.9
8 7.0
9
then things become a bit more complicated, see e.g. column with empty datapoints.
Upvotes: 3