2
votes

I have a data files including multiple float-value columns such as following and I want to plot some columns in gnuplot.

1.08 1.6 4.83
1.53 2.5 5.95
2.11 3.2 6.1
2.60 4.1 7.0

I want to have x2-axis by following:

set xtics nomirror
set x2tics
set autoscale xfix
set autoscale x2fix
set ylabel 'Y_H
set xlabel 'Y_O'
set x2label 'Y_C'
p  'datafile' u 1:2 w l ls 1 t '',\
   '' u 1:(NaN):x2ticlabels(3) axes x2y1 w l ls 1 t ''

This way displays every single tic and It's label on the x2 axis. I would like to set custom labels for x2-axis such as 4,5,6,7 and their tics to write. How can I have custom labels and tics on x2-axis?

1
Hi, welcome to SO, is there a particular reason you use x2ticlabels(3) in your plot command? - Zahaib Akhtar
No. I used x2tics(3) without any difference. - HosseinFGM
I asked because with that you will get the third column in your data file as the x2labels. If you don't want that then you will need to change the plot to 1:(Nan):3 and just set x2range like set x2range[4.83:7] - Zahaib Akhtar
Thanks, I was the answer. - HosseinFGM
Okay I've added an answer with some explanation as well. - Zahaib Akhtar

1 Answers

3
votes

x2tics behave the same way as xtics so all functions available for xtics are also applicable to x2tics.

Set a range by:

set x2range [1:5] 

This command will give you a range of 1 to 5 on the x2 axis.

If you want to set custom labels then:

set x2tics ("one" 1, "two" 2, "three" 3, "four" 4, "five" 5)

This command will give you the words inside double quotes at x2=1, x2=2 and so on.

In your case you can get numerical values on x2 axis by using set x2range [4.83:7] and changing second plot to 1:(NaN):3