我同时使用 ytics 和 y2tics,因为我的数据范围大不相同。通过使用两个轴,所有数据都按比例表示。请参阅此示例图像:
“集群”、“主机”和“vsan”数据使用 y2 轴,其余使用 yaxis。如何根据绘制的轴将键移动到(图表的)左上角或右上角?
这是我的代码的摘录:
set y2tics
set ytics nomirror
plot "data" using 1:2 title "Clusters" linecolor rgb "black" axes x1y2, \
'' using 1:3 title "Hosts" linecolor rgb "blue" axes x1y2,\
'' using 1:4 title "vSAN" linecolor rgb "cyan" axes x1y2,\
'' using 1:5 title "VMs" linecolor rgb "purple" axes x1y1,\
'' using 1:6 title "⚫" linecolor rgb "green" axes x1y1,\
'' using 1:7 title "⚪" linecolor rgb "red" axes x1y1
这是一些示例测试数据:
2016-12-18 22 131 0 1179 1024 155
2016-12-19 22 131 0 1179 1025 154
2016-12-20 22 131 0 1178 1025 153
2016-12-21 22 129 0 1180 1026 154
2016-12-22 22 132 0 1182 1014 168
2016-12-23 22 133 0 1182 1016 166
2016-12-24 22 133 0 1187 1016 171
2016-12-25 22 133 0 1187 1016 171
2016-12-26 22 133 0 1187 1016 171
2016-12-27 22 133 0 1187 1016 171
2016-12-28 22 133 0 1189 1017 172
2016-12-29 22 133 0 1189 1018 171
2016-12-30 22 133 0 1189 1018 171
2017-01-01 22 133 0 1189 1018 171
2017-01-02 22 133 0 1189 1018 171
2017-01-03 22 133 0 1185 1020 165
2017-01-04 22 133 0 1183 1018 165
2017-01-05 22 133 0 1183 1017 166
2017-01-06 22 133 0 1174 1018 156
2017-01-07 22 133 0 1173 1018 155
2017-01-08 22 133 0 1173 1018 155
2017-01-09 22 133 0 1175 1011 164
2017-01-10 22 131 0 1170 1004 166
2017-01-11 22 131 0 1170 1004 166
2017-01-13 22 131 0 1162 998 164
根据 Maij 的回答更新了示例图片:
最佳答案
如果“到左侧或右侧”是指图形区域的两侧,那么您可以使用 multiplot
环境。我们必须手动调整边距,并且必须注意不要将 y 坐标打印在错误的一侧。
set samples 1000
set xrange [0:2*pi]
# The plots must overlap, so we set the margins manually.
# We have to play with the numbers, the depend on the terminal.
set lmargin at screen 0.25
set rmargin at screen 0.75
set key outside
set terminal pngcairo size 800,400
set output "two_keys.png"
set multiplot
# no ytics on the right side for the first plot
set ytics nomirror
set key left
plot sin(x) lt 2, \
cos(x) lt 3
# no ytics on the left side for the second plot
unset ytics
set y2tics
set y2range [-10:10]
set key right
plot tan(x) axis x1y2 lt 4
unset multiplot
关于key - gnuplot:根据绘制的轴在左侧或右侧设置键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41645963/