1# This example shows how a nonlinear axis definition can be used to
2# create a "broken axis". X coordinates 0-100 are at the left,
3# X coordinates 500-1000 are at the right, there is a small gap between them.
4# So long as no data points with (100 < x < 500) are plotted, this works as expected.
5#
6# f(x) maps x axis (discontinuous) to shadow axis coords (continuous linear range [0:1000])
7# g(x) maps shadow axis coords to x axis readout
8#
9  set title "A 'broken' x axis can be defined using 'set nonlinear x'"
10
11# Define the broken-axis mapping
12  axis_gap = 25.
13  f(x) = (x <= 100) ? x : (x < 500) ? NaN : (x - 400 + axis_gap)
14  g(x) = (x <= 100) ? x : (x < 100 + axis_gap) ? NaN : (x + 400 - axis_gap)
15  set xrange [15:600] noextend
16  set nonlinear x via f(x) inverse g(x)
17
18  set xtics 50.
19  set xtics rotate by -90 nomirror
20  set ytics nomirror
21  set border 3
22  unset key
23
24# Creation of the broken axis marks (this should be automated)
25  set arrow 500 from 100, graph 0 to 500, graph 0 nohead lt 500 lw 2 lc bgnd front
26  set arrow 501 from 100, graph 0 length graph  .01 angle 75 nohead lw 2 front
27  set arrow 502 from 100, graph 0 length graph -.01 angle 75 nohead lw 2 front
28  set arrow 503 from 500, graph 0 length graph  .01 angle 75 nohead lw 2 front
29  set arrow 504 from 500, graph 0 length graph -.01 angle 75 nohead lw 2 front
30
31  plot 'silver.dat' with yerrorbars lw 2, '' with lines
32#
33  pause -1 "<cr> to continue"
34  reset
35