如何在 Gnuplot 中使用从右到左的 x 轴在图上显示 "smooth csplines" 曲线
How to show "smooth csplines" curve on plot with right-to-left x-axis in Gnuplot
我有这个简单的独立 gnuplot 脚本:
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
点和 csplines
曲线在输出中显示得很好:
但是现在看看当我通过将 xrange
行更改为:
来反转 x 轴方向时会发生什么
set xrange [50:30]
其他一切都保持不变,csplines
曲线现在从输出中丢失,而点仍然正确显示:
如何让 csplines
曲线出现在第二种情况下?
(即使用从右到左的轴。)
看来输出确实不理想。使用 Gnuplot 5.0.6,我得到一个空图,如问题中所示,而使用 Gnuplot 5.2.2,该图如下所示:
作为修复,可以先构造插值,通过 set table
将其保存到文件中,然后按 "reversed" 顺序将所有内容绘制在一起:
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
这会产生:
编辑:
set table
命令可以与数据块结合使用,以避免创建临时文件(如果需要):
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
我有这个简单的独立 gnuplot 脚本:
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
点和 csplines
曲线在输出中显示得很好:
但是现在看看当我通过将 xrange
行更改为:
set xrange [50:30]
其他一切都保持不变,csplines
曲线现在从输出中丢失,而点仍然正确显示:
如何让 csplines
曲线出现在第二种情况下?
(即使用从右到左的轴。)
看来输出确实不理想。使用 Gnuplot 5.0.6,我得到一个空图,如问题中所示,而使用 Gnuplot 5.2.2,该图如下所示:
作为修复,可以先构造插值,通过 set table
将其保存到文件中,然后按 "reversed" 顺序将所有内容绘制在一起:
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
这会产生:
编辑:
set table
命令可以与数据块结合使用,以避免创建临时文件(如果需要):
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