I have a .txt file contatning points which is look like following:
##x1 y1 x2 y2
123 567 798 900
788 900 87 89
....
I want to draw 2D diagram which link each pair in line of the .txt file using gnuplot.
Edit1:
I find this Draw points and lines in gnuplot, but I don't know how to use gnuplot in my case.
Edit2:
There is no limit for the diagram type. As I see here I could set terminal to png using following:
set terminal png
For line style I find this example here:
set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 ps 1.5
and there is no need for lable for axes.
You can also do this using
rsvg-convert
(from librsvg) orsvg2png
. Both of those programs expect an inout file in SVG format and render it as a PNG file. So you would need to convert yourinto this type of thing
That can be done easily enough with a little
awk
script like this:You can then pump the output of that into either of the two programs I mentioned above:
Updated
In the light of your reply about the number of lines and the maximum x,y dimensions, my original, ImageMagick-based approach at the bottom of this answer is clearly NOT the right one for your specific problem. However, I will leave it for others to see as it would be perfectly fine for up to a few dozen lines. I am now providing a more appropriate
gnuplot
version.Gnuplot Version
If you want to do it with
gnuplot
, it would look something like this:If you save that in a file calle
plot.cmd
, you can then run it withIf you want arrowheads, use a variant like this:
Magick++ and C++ Answer
I decided to work out a Magick++ and C++ answer, just for fun. The code looks like this - and the command to compile is shown in the comments at the top.
I generated 1,000 lines of random test data with Perl like this:
The result looks like this:
Original Answer
You could also do it quite easily with ImageMagick which is already installed on most Linux distros anyway. There are actually only 4 lines of code in the following - the rest is all comments:
Output