Vector field using gnuplot

后端 未结 2 1822
轻奢々
轻奢々 2021-02-13 13:47

How do I plot a vector field, where the direction at each point (x, y) is given by tangent(alpha) = f(x, y)?

2条回答
  •  醉梦人生
    2021-02-13 13:57

    As far as I can tell, gnuplot can only plot vector fields when reading data from a file. Your file will have to have 4 columns, x, y, deltax and delta y, and gnuplot will then plot a vector from (x,y) to (x+deltax, y+deltay) for each line in the file:

    plot "file.dat" using 1:2:3:4 with vectors head filled lt 2
    

    If you are not insisting on using gnuplot, there are other tools that can to this better or at least easier. I personally use asymptote. There is an example of a vectorfield plotted in asymptote here.

提交回复
热议问题