Q:

How to add a gap in gnuplot line when introducing a relative shift in x-axis?

I have a data file called data_file.dat which has two columns and 10 rows like this:
   #1   2
   1    2
   2    4
   3    6
   4    8
   5    16
   6    9
   7    7
   8    5
   9    3
   10   2 

I am using gnuplot to plot the data points with a line and I have to produce a relative shift in the x-axis with the x value corresponding to the maximum y being at the origin. To do that, I use this:
    stats "data_file.dat" u 2 name "A"
    stats 'data_file.dat' using 1 every ::A_index_max::A_index_max nooutput
    A_pos_max_y = STATS_max
    plot 'data_file.dat' u ($1<A_pos_max_y ? $1+10-A_pos_max_y : $1-A_pos_max_y):2 w l

The output is this. I need to remove the line which connects the y values at initial and final values of x. How do I make this 'gap' between those two points?
I checked this one solution How to add a gap in gnuplot line? but because I don't have 'missing points' and my file is too large (way more than 10 rows) to do this manually, this is not helpful. Also, I am using stats to find maximum valued points, so I don't know where to produce the gap in my data file from the very beginning.

A:

You must plot the two parts separately:
stats "data_file.dat" u 2 name "A"
stats 'data_file.dat' using 1 every ::A_index_max::A_index_max nooutput
A_pos_max_y = STATS_max

set style data lines
plot 'data_file.dat' u ($1<A_pos_max_y ? $1+10-A_pos_max_y : 1/0):2 lt 1
    '' u ($1 >= A_pos_max_y ? $1-A_pos_max_y : 1/0):2 lt 1 t ''

The 1/0 results in invalid points which are silently skipped during plotting.

