Search code examples
gnuplotcoordinate-systems

Plotting a coordinate system with gnuplot


Generally I like the look of gnuplot plots. However I have to prepare a plot for a group of people who have only ever seen old style/traditional x-y coordinate systems with x=0 and y=0 axes. In order not to confuse them, I would stick to their preferred style.

How do I achieve this in gnuplot?

I found set xzeroaxis which gives me the x-axis. (similar for the y-axis). Still I need to:

  • get rid of the frame
  • put the tic labels/numbers on the x/y-axis
  • have an arrowhead at the end of the axis

How can I achieve this?


Solution

  • set xzeroaxis
    set yzeroaxis
    set border 0          # remove frame
    set xtics axis        # place tics on axis rather than on border
    set ytics axis
    set ticscale 0        # [optional] labels only, no tics
    set xtics add ("" 0)  # suppress origin label that lies on top of axis
    set ytics add ("" 0)  # suppress origin label that lies on top of axis
    #
    # if arrows are wanted only in the positive direction
    set arrow 1 from 0,0 to graph 1, first 0 filled head
    set arrow 2 from 0,0 to first 0, graph 1 filled head
    #
    # if arrows in both directions from the origin are wanted
    set arrow 3 from 0,0 to graph 0, first 0 filled head
    set arrow 4 from 0,0 to first 0, graph 0 filled head
    
    plot f(x)
    

    enter image description here