gnuplot:如何创建彩色网格区域,而不仅仅是彩色网格线?
gnuplot: How to create colored grid regions, not just colored grid lines?
我正在使用 "gnuplot 5.2 patchlevel 2"。我正在尝试创建背景网格彩色列或彩色区域,如下图所示。到目前为止,我只能为网格线着色。但我想给网格区域上色。什么是最好的方法?这是我的代码:
set terminal svg
set output 'out.svg'
set key off
set xlabel 'X'
set ylabel 'Y'
set title 'Data'
set grid
set grid xtics lw 0.25 lc rgb "#ff0000" # line only, but I want to color the whole area
#unset grid
#set grid ytics lt 0 lw 1 lc rgb "#0000ff"
set xrange [0:4]
set yrange [0:100]
set tics scale 0.5
set xtics nomirror
set ytics nomirror
set style fill solid noborder
set linetype 1 lc rgb 'red' lw 0.35
set linetype 2 lc rgb '#009900'
set linetype 3 lc rgb 'black' lw 0.5
set boxwidth 0.5 relative
set style fill solid border lc rgb "black"
plot "data.txt" using 1:2:4:3:5:( < ? 1 : 2) linecolor variable with candlesticks, \
"data.txt" using 1:6 with lines lt 3, \
"data.txt" using 1:5:7 with filledcurves fs transparent solid 0.3 lc rgb "blue"
这是我的绘图示例 data.txt 文件:
1 10 30 5 20 23 29
2 25 45 10 30 34 37
3 30 50 20 25 47 53
您可以使用像 [x=0:16:1] '+' us (x/2):(100/(int(x)%4!=1)) with filledcurves x1
这样的虚拟函数。
每四个点生成一个 NaN
并中断曲线。
$data <<EOD
1 10 30 5 20 23 29
2 25 45 10 30 34 37
3 30 50 20 25 47 53
5 10 30 5 20 23 29
7 25 45 10 30 34 37
8 30 50 20 25 47 53
EOD
set style fill solid noborder
set linetype 1 lc rgb 'red' lw 0.35
set linetype 2 lc rgb '#009900'
set linetype 3 lc rgb 'black' lw 0.5
set boxwidth 0.5 relative
set style fill solid border lc rgb "black"
plot sample [x=0:16:1] '+' us (x/2):(100/(int(x)%4!=1)) with filledcurves x1 fc rgb "#EEEEEE",\
$data using 1:2:4:3:5:( < ? 1 : 2) linecolor variable with candlesticks, \
$data using 1:6 with lines lt 3, \
$data using 1:5:7 with filledcurves fs transparent solid 0.3 lc rgb "blue"
此函数也可以分配给固定 y2range
的 y2
轴,这对于带缩放的交互式绘图可能更方便。
我正在使用 "gnuplot 5.2 patchlevel 2"。我正在尝试创建背景网格彩色列或彩色区域,如下图所示。到目前为止,我只能为网格线着色。但我想给网格区域上色。什么是最好的方法?这是我的代码:
set terminal svg
set output 'out.svg'
set key off
set xlabel 'X'
set ylabel 'Y'
set title 'Data'
set grid
set grid xtics lw 0.25 lc rgb "#ff0000" # line only, but I want to color the whole area
#unset grid
#set grid ytics lt 0 lw 1 lc rgb "#0000ff"
set xrange [0:4]
set yrange [0:100]
set tics scale 0.5
set xtics nomirror
set ytics nomirror
set style fill solid noborder
set linetype 1 lc rgb 'red' lw 0.35
set linetype 2 lc rgb '#009900'
set linetype 3 lc rgb 'black' lw 0.5
set boxwidth 0.5 relative
set style fill solid border lc rgb "black"
plot "data.txt" using 1:2:4:3:5:( < ? 1 : 2) linecolor variable with candlesticks, \
"data.txt" using 1:6 with lines lt 3, \
"data.txt" using 1:5:7 with filledcurves fs transparent solid 0.3 lc rgb "blue"
这是我的绘图示例 data.txt 文件:
1 10 30 5 20 23 29
2 25 45 10 30 34 37
3 30 50 20 25 47 53
您可以使用像 [x=0:16:1] '+' us (x/2):(100/(int(x)%4!=1)) with filledcurves x1
这样的虚拟函数。
每四个点生成一个 NaN
并中断曲线。
$data <<EOD
1 10 30 5 20 23 29
2 25 45 10 30 34 37
3 30 50 20 25 47 53
5 10 30 5 20 23 29
7 25 45 10 30 34 37
8 30 50 20 25 47 53
EOD
set style fill solid noborder
set linetype 1 lc rgb 'red' lw 0.35
set linetype 2 lc rgb '#009900'
set linetype 3 lc rgb 'black' lw 0.5
set boxwidth 0.5 relative
set style fill solid border lc rgb "black"
plot sample [x=0:16:1] '+' us (x/2):(100/(int(x)%4!=1)) with filledcurves x1 fc rgb "#EEEEEE",\
$data using 1:2:4:3:5:( < ? 1 : 2) linecolor variable with candlesticks, \
$data using 1:6 with lines lt 3, \
$data using 1:5:7 with filledcurves fs transparent solid 0.3 lc rgb "blue"
此函数也可以分配给固定 y2range
的 y2
轴,这对于带缩放的交互式绘图可能更方便。