How to label vector in gnuplot

安稳与你 提交于 2019-12-20 04:48:08

问题


I would like to know how to give a label at the end of a vector in gnuplot. I know it is possible to use "set" in gnuplot to show a certain label at some place, but I have hundreds of vectors to draw, and I want to show the index of each vector at its end, e.g., "Node n". Thus I wonder if it is possible to show the labels with incremental index in "one step" with corresponding vectors.

My OS is Ubuntu 13.04 32bit version. Thanks for any advice!


回答1:


Imagine you have a file with the following data (which I named "temp"), where the first two coordinates are the origin and the last two coordinates are the x and y components (projections) of your vector:

0 0 1 1
0 0 1 2
0 0 1 3
0 0 1 4
0 0 1 5

Then you can do what you want with the following commands:

set xrange [0:1.2]
set yrange [0:6]
plot "temp" with vectors, "temp" u 3:4:0 with labels left

The first instance in plot is to plot the vectors with the same convention I mentioned above in the data file, the second instance is to place a label with coordinates x = column 3 and y = column 4 (that is, at the end of your vectors), with text = column 0 (which gives the order of your data entries) and flush it to the left from those coordinates. It looks like this:



来源:https://stackoverflow.com/questions/23088043/how-to-label-vector-in-gnuplot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!