Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In gnuplot, how to label each point in the plot with its coordinates?

Tags:

gnuplot

I have a data file, abc.dat and I want to plot it with labeling each coordinate like (1,5), (4,6), (2,8) and so on ....

abc.dat is like :

1  5
4  6
2  8
4  5
7  8
8  9
3  4
like image 238
hkchakladar Avatar asked Apr 20 '14 02:04

hkchakladar


People also ask

How do you write subscripts in gnuplot?

You can write the supersript as X^2, and the subscript is Y_3. To make several letters super- / sub-script, you need brace like Z_{64}. To use super and subscripts at the same time, try Z@^2_{64}. The following is an example to make legends with the superscripts.

How use gnuplot to plot data from a file?

To plot functions simply type: plot [function] at the gnuplot> prompt. Discrete data contained in a file can be displayed by specifying the name of the data file (enclosed in quotes) on the plot or splot command line. Data files should have the data arranged in columns of numbers.

Does gnuplot support multiple Y axes on a single plot?

5.9 Does gnuplot support multiple y-axes on a single plot? Yes. 2D plots can have separate x axes at the bottom (x1) and top (x2), and separate y axes at the left (y1) and right (y2).


1 Answers

Use the labels plotting style for this. That requires three using specifiers: x-value, y-value and a string which is placed at the given coordinates. So the easiest command would be:

plot 'abc.dat' using 1:2:(sprintf("(%d, %d)", $1, $2)) with labels notitle

That places the respective labels centered at the coordinates.

The following command plots a point at the respective coordinate and places the coordinate label a bit shifted near to it:

set offset 1,1,1,1
plot 'abc.dat' using 1:2:(sprintf("(%d, %d)", $1, $2)) with labels point  pt 7 offset char 1,1 notitle

The result with 4.6.4 is:

enter image description here

like image 160
Christoph Avatar answered Sep 20 '22 05:09

Christoph