I have this simple self-contained gnuplot script:
set terminal png size 400,300
set output 'test.png'
unset key
set xrange [30:50]
$data << EOD
42, 5.7
44, 8.1
46, 8.9
48, 9.2
50, 9.3
EOD
plot "$data" using 1:2 smooth csplines, \
"$data" using 1:2 with points
Both the points and the csplines
curve show up just fine in the output:
But now watch what happens when I reverse the x-axis direction by changing the xrange
line to:
set xrange [50:30]
Everything else kept the same, the csplines
curve is now missing from the output, whereas the points still show up correctly:
How can I get the csplines
curve to show up in the second case?
(i.e. with the right-to-left axis.)
It does indeed seem that the output is not ideal. With Gnuplot 5.0.6, I get an empty plot as shown in the question while with Gnuplot 5.2.2, the figure looks like this:
As a fix, one could construct the interpolation first, save it via set table
into a file and then plot everything together in the "reversed" order:
unset key
set xrange [30:50]
$data << EOD
42, 5.7
44, 8.1
46, 8.9
48, 9.2
50, 9.3
EOD
set table 'meta.csplines.dat'
plot "$data" using 1:2 smooth csplines
unset table
set xrange [50:30]
plot 'meta.csplines.dat' using 1:2 w l lw 2, \
"$data" using 1:2 with points
This produces:
EDIT:
The set table
command can be used in combination with a data block in order to avoid creating a temporary file (should the need arise):
unset key
set xrange [30:50]
$data << EOD
42, 5.7
44, 8.1
46, 8.9
48, 9.2
50, 9.3
EOD
set table $meta
plot "$data" using 1:2 smooth csplines
unset table
set xrange [50:30]
plot "$meta" using 1:2 w l lw 2, \
"$data" using 1:2 with points