Martin
Martin

Reputation: 40613

How to prevent labels to overlap

I am running the following command to draw a few X,Y points in gnuplot:

plot "Output.tsv" using ($2+3):($3+3):1 with labels, "Output.tsv" using 2:3

Some of the data points are very close to each other and it makes the label unreadable. Is there a way to ask gnuplot to eliminate/reduce the overlap between labels?

enter image description here

Upvotes: 3

Views: 2993

Answers (1)

Martin
Martin

Reputation: 1114

I think you could consider 3 options:

1) make your graph huge and hope your labels do not overlap
2) plot the points as different series with each item having its own legend
3) use letters instead of labels, you can put a letter at each point using

plot "???" using 1:2
plot "" using 1:2:(stringcolumn(3) ne 'compare to' ? 'if equal' : 'if not equal' ) with labels

the stringcolumn function looks in column 3, compares the value to the string 'compareto' and if there is a match it puts 'if equal' at that location, otherwise 'if not equal'

Hence, I see something like Simulator in your graph, you could keep the green point and put an S with it/on it using

plot "" using 1:2:(stringcolumn(3) ne 'Simulator' ? 'S' : '' ) with labels

I hope this helps.

Upvotes: 6

Related Questions