Search code examples
gnuplotcylindrical

gnuplot: how to make lines between points an arc


I have points data in cylindrical coordinates. Can I make them arc like here. Now lines look like those


Solution

  • To do this with a data file, you can use set dgrid3d and the set table output. The data that you have looks like this:

    set pm3d
    splot "data" u ($1*cos($2)):($1*sin($2)):3 w l
    

    enter image description here

    You can make an interpolation with set dgrid3d to improve the resolution:

    set dgrid3d splines 20,20
    set table "table"
    splot "data" u 1:(acos(cos($2))):3
    

    Now your refined grid data is saved in file "table". Note I sent the angle variable back to the 0 to pi interval to improve the interpolation. It's important to use the splines option, otherwise your data will be interpolated using all the data points, rather than only the neighboring ones. Plot this new data:

    set pm3d
    splot "table" u ($1*cos($2)):($1*sin($2)):3 w l
    

    enter image description here

    More data means the straight lines look less straight because there are more of them. You don't need to use the interpolate option with set pm3d, just adjust the number of scans of the set dgrid3d option.