Search code examples
gnuplot

Plot y1 in x1 with respect to x2 axis


I have a data a follows:

y1   x1   x2
125  100   1
130  90    2
136  85    3
143  70    4
145  65    5

I would like to plot it in gnuplot as in the figure.enter image description here

I used the procedure mentioned here Gnuplot: Plot x2 axis with respect to x1 axis , but it is plotting the x2 differently.


Solution

  • Plot your data as usual on the x1 and y1 axes, but place additional labels on the x2-axis with x2tic(3):

    set xrange [*:*] reverse
    set x2tics
    set xtics nomirror
    plot 'file.dat' using 2:1:x2tic(3) with linespoints pt 7 notitle
    

    enter image description here

    If you don't want a conventional numerical, you could also use both x2tic and xtic:

    plot 'file.dat' using 2:1:x2tic(3):xtic(2) with linespoints pt 7 notitle
    

    enter image description here