更新gnuplot5中的数据块
我正在使用Gnuplot 5.0中引入的新特性创建一个数据块,并使用以下代码对其进行绘图更新gnuplot5中的数据块,gnuplot,Gnuplot,我正在使用Gnuplot 5.0中引入的新特性创建一个数据块,并使用以下代码对其进行绘图 #set term wxt enhanced 0 font 'Helvetica,' noraise # set labels set title 'Sample Points' set xlabel 'X pos' offset -5 set ylabel 'Y pos' offset 3 set zlabel 'Speed' offset -2 rotate left set key outside
#set term wxt enhanced 0 font 'Helvetica,' noraise
# set labels
set title 'Sample Points'
set xlabel 'X pos' offset -5
set ylabel 'Y pos' offset 3
set zlabel 'Speed' offset -2 rotate left
set key outside right top box
set grid
set border 4095
set xtics 20
set ytics 20
set style line 1 pointtype 7 pointsize 1 lc rgb 'red'
set style line 2 pointtype 7 pointsize 1 lc rgb 'green'
set style line 3 pointtype 7 pointsize 1 lc rgb 'blue'
# loop begin
$data << EOD
821.328349 898.350000 18.887529 0
901.650000 821.328349 18.887529 1
898.350000 978.671651 18.887529 2
978.671651 901.650000 18.887529 3
823.181732 898.350000 18.533830 0
901.650000 823.181732 18.533830 1
898.350000 976.818268 18.533830 2
976.818268 901.650000 18.533830 3
824.999809 898.350000 18.180776 0
901.650000 824.999809 18.180776 1
898.350000 975.000191 18.180776 2
975.000191 901.650000 18.180776 3
826.782868 898.350000 17.830582 0
901.650000 826.782868 17.830582 1
898.350000 973.217132 17.830582 2
973.217132 901.650000 17.830582 3
828.531204 898.350000 17.483360 0
901.650000 828.531204 17.483360 1
898.350000 971.468796 17.483360 2
971.468796 901.650000 17.483360 3
830.244850 898.350000 17.136468 0
901.650000 830.244850 17.136468 1
898.350000 969.755150 17.136468 2
969.755150 901.650000 17.136468 3
831.924084 898.350000 16.792338 0
901.650000 831.924084 16.792338 1
898.350000 968.075916 16.792338 2
968.075916 901.650000 16.792338 3
833.569227 898.350000 16.451429 0
901.650000 833.569227 16.451429 1
898.350000 966.430773 16.451429 2
966.430773 901.650000 16.451429 3
835.180379 898.350000 16.111523 0
901.650000 835.180379 16.111523 1
898.350000 964.819621 16.111523 2
964.819621 901.650000 16.111523 3
836.757776 898.350000 15.773971 0
901.650000 836.757776 15.773971 1
898.350000 963.242224 15.773971 2
963.242224 901.650000 15.773971 3
838.301768 898.350000 15.439919 0
901.650000 838.301768 15.439919 1
898.350000 961.698232 15.439919 2
961.698232 901.650000 15.439919 3
839.812485 898.350000 15.107162 0
901.650000 839.812485 15.107162 1
898.350000 960.187515 15.107162 2
960.187515 901.650000 15.107162 3
841.290161 898.350000 14.776766 0
901.650000 841.290161 14.776766 1
898.350000 958.709839 14.776766 2
958.709839 901.650000 14.776766 3
842.735180 898.350000 14.450189 0
901.650000 842.735180 14.450189 1
898.350000 957.264820 14.450189 2
957.264820 901.650000 14.450189 3
844.147653 898.350000 14.124734 0
901.650000 844.147653 14.124734 1
898.350000 955.852347 14.124734 2
955.852347 901.650000 14.124734 3
845.527869 898.350000 13.802154 0
901.650000 845.527869 13.802154 1
898.350000 954.472131 13.802154 2
954.472131 901.650000 13.802154 3
846.876245 898.350000 13.483757 0
901.650000 846.876245 13.483757 1
898.350000 953.123755 13.483757 2
953.123755 901.650000 13.483757 3
848.192819 898.350000 13.165744 0
901.650000 848.192819 13.165744 1
898.350000 951.807181 13.165744 2
951.807181 901.650000 13.165744 3
849.477992 898.350000 12.851735 0
901.650000 849.477992 12.851735 1
898.350000 950.522008 12.851735 2
950.522008 901.650000 12.851735 3
850.732123 898.350000 12.541306 0
901.650000 850.732123 12.541306 1
898.350000 949.267877 12.541306 2
949.267877 901.650000 12.541306 3
851.955313 898.350000 12.231900 0
901.650000 851.955313 12.231900 1
898.350000 948.044687 12.231900 2
948.044687 901.650000 12.231900 3
853.148046 898.350000 11.927332 0
901.650000 853.148046 11.927332 1
898.350000 946.851954 11.927332 2
946.851954 901.650000 11.927332 3
854.310507 898.350000 11.624608 0
901.650000 854.310507 11.624608 1
898.350000 945.689493 11.624608 2
945.689493 901.650000 11.624608 3
855.443020 898.350000 11.325128 0
901.650000 855.443020 11.325128 1
898.350000 944.556980 11.325128 2
944.556980 901.650000 11.325128 3
856.546040 898.350000 11.030203 0
901.650000 856.546040 11.030203 1
898.350000 943.453960 11.030203 2
943.453960 901.650000 11.030203 3
857.619649 898.350000 10.736086 0
901.650000 857.619649 10.736086 1
898.350000 942.380351 10.736086 2
942.380351 901.650000 10.736086 3
858.664411 898.350000 10.447624 0
901.650000 858.664411 10.447624 1
898.350000 941.335589 10.447624 2
941.335589 901.650000 10.447624 3
859.680471 898.350000 10.160601 0
901.650000 859.680471 10.160601 1
898.350000 940.319529 10.160601 2
940.319529 901.650000 10.160601 3
860.668283 898.350000 9.878115 0
901.650000 860.668283 9.878115 1
898.350000 939.331717 9.878115 2
939.331717 901.650000 9.878115 3
861.628190 898.350000 9.599073 0
901.650000 861.628190 9.599073 1
898.350000 938.371810 9.599073 2
938.371810 901.650000 9.599073 3
862.560481 898.350000 9.322910 0
901.650000 862.560481 9.322910 1
898.350000 937.439519 9.322910 2
937.439519 901.650000 9.322910 3
863.465671 898.350000 9.051895 0
901.650000 863.465671 9.051895 1
898.350000 936.534329 9.051895 2
936.534329 901.650000 9.051895 3
864.343914 898.350000 8.782434 0
901.650000 864.343914 8.782434 1
898.350000 935.656086 8.782434 2
935.656086 901.650000 8.782434 3
865.195863 898.350000 8.519487 0
901.650000 865.195863 8.519487 1
898.350000 934.804137 8.519487 2
934.804137 901.650000 8.519487 3
866.021577 898.350000 8.257141 0
901.650000 866.021577 8.257141 1
898.350000 933.978423 8.257141 2
933.978423 901.650000 8.257141 3
866.821806 898.350000 8.002291 0
901.650000 866.821806 8.002291 1
898.350000 933.178194 8.002291 2
933.178194 901.650000 8.002291 3
867.596557 898.350000 7.747514 0
901.650000 867.596557 7.747514 1
898.350000 932.403443 7.747514 2
932.403443 901.650000 7.747514 3
868.346635 898.350000 7.500778 0
901.650000 868.346635 7.500778 1
898.350000 931.653365 7.500778 2
931.653365 901.650000 7.500778 3
869.072042 898.350000 7.254067 0
901.650000 869.072042 7.254067 1
898.350000 930.927958 7.254067 2
930.927958 901.650000 7.254067 3
869.773586 898.350000 7.015447 0
901.650000 869.773586 7.015447 1
898.350000 930.226414 7.015447 2
930.226414 901.650000 7.015447 3
EOD
splot '$data' index 0 using 1:2:3 with points ls 1 title 'class 1',\
'' index 1 using 1:2:3 with points ls 2 title 'class 2',\
'' index 2 using 1:2:3 with points ls 3 title 'class 3',\
'' index 3 using 1:2:3 with points ls 1 title 'class 4',\
'' index 4 using 1:2:3 with points ls 2 title 'class 5',\
'' index 5 using 1:2:3 with points ls 3 title 'class 6',\
'' index 6 using 1:2:3 with points ls 1 title 'class 7',\
'' index 7 using 1:2:3 with points ls 2 title 'class 8'
# loop end
#设置术语wxt增强型0字体'Helvetica',noraise
#设置标签
设置标题“采样点”
设置xlabel'X pos'偏移量-5
设置Y标签“Y位置”偏移量3
设置Z标签“速度”偏移-2向左旋转
将钥匙置于右顶箱外部
设置网格
设置边框4095
设置xtics 20
设置ytics 20
设置样式行1点类型7点大小1 lc rgb“红色”
设置样式线2点类型7点大小1 lc rgb“绿色”
设置样式线3点类型7点大小1 lc rgb“蓝色”
#循环开始
$data您可以打印到数据块,包括覆盖或附加数据块。假设我使用
$k << EOD
1 2
2 3
4 5
EOD
现在我的数据块$k看起来像
1 2
2 3
4 5
5 6
我甚至可以通过打印空行来创建多个块。例如,如果我希望使用现有的$k创建一个包含两个块的新$l(无附加,因为我不需要附加到现有块),我可以这样做
set print $l
print $k
print ""
print $k
set print
这将创建一个新的块$l,其中包含
1 2
2 3
4 5
5 6
1 2
2 3
4 5
5 6
不幸的是,这将在$k的每个副本后插入一个空行(因为print命令添加了一个换行删除器,而块已经有了一个),因此如果您需要重复相同的基数并向每个块添加一些额外的行,这将不起作用。将数据存储在字符串中可以实现这一点
bse = "1 2\n2 3\n4 5"
set print $l
print bse
print "5 6"
print ""
print ""
print bse
print "7 8"
set print
这将产生
1 2
2 3
4 5
5 6
1 2
2 3
4 5
7 8
1 2
2 3
4 5
5 6
1 2
2 3
4 5
7 8