How to draw 2D diagram in linux

前端 未结 2 1644
别那么骄傲
别那么骄傲 2021-01-28 23:03

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

2条回答
  •  花落未央
    2021-01-28 23:24

    You can also do this using rsvg-convert (from librsvg) or svg2png. Both of those programs expect an inout file in SVG format and render it as a PNG file. So you would need to convert your

    123 567 798 900
    788 900 87  89
    

    into this type of thing

    
      
      
    
    

    That can be done easily enough with a little awk script like this:

    awk '
       BEGIN{ printf("\n") }
    
      {
         x1=$1; y1=$2; x2=$3; y2=$4;
         printf("\n")
      }
    
      END{ printf("\n") }' points.txt
    

    You can then pump the output of that into either of the two programs I mentioned above:

    awk ... | rsvg-convert -b \#ffff00 > result.png
    

提交回复
热议问题