Xtics与GnuPlot距离太近,并且有很多数据点

问题描述 投票:0回答:1

我正在尝试绘制大约15,000个不同数据点的图形。我尝试了所有可以想到的各种变化以减少xtics的数量,但是我似乎无法更改其绘制频率。

这是我的gnuplot文件:

reset
# need to call with two variables -e "filename='...'" -e "machine='...'"
set title machine." Activity ".filename
set datafile separator ","
set autoscale x
set autoscale y
set autoscale y2
set yrange [0:*]
set y2range [0:*]
set y2tics
set style data lines
set ylabel "% CPU"
set xlabel "Time"
set y2label "Memory (MB)"
set bmargin 7 # room for the xtic label
set term pngcairo size 960,720
set output filename.".png"
# I've also tried autofreq and explicit labels
set xtics axis out rotate 90 scale 0.5 (20101939, 1000000, 25102219)
plot filename \
  using 2:xtic(1) title "CPU" with points pt 1 axes x1y1, \
  "" using ($3 / 1024 / 1024):xtic(1) title "Memory" with points pt 1 axes x1y2

我的数据格式为:

datetime(ddHHMMss), %cpu, mem-in-bytes, pid, process-alias, process-name

我的数据如下所示(每15秒记录每30秒进行一次采样):

20101939,0,137932800,6172,process-alias,process-name
20102009,0.15623667978147077,139509760,6172,process-alias,process-name
20102039,0.15623669540380838,139866112,6172,process-alias,process-name
20102109,0.41663098777764329,141488128,6172,process-alias,process-name
20102139,0.052078915131769939,141455360,6172,process-alias,process-name

尽管我的xtics命令具有明确的开始,间隔和结束,但是我的图形总是以xtic标签重叠而结束。外观如下:

graph with overlapping xtic labels

gnuplot
1个回答
0
投票

要过滤tic标签,请用打印非空白标签的标准替换xtic(1)。例如,这将每隔25个标签打印一次。

 plot filename \
   using 2:xtic( int($0)%25 ? "" : strcol(1) ) title "CPU" with points pt 1

int($ 0)是行号; strcol(1)是列1的内容,以字符串形式读取]

© www.soinside.com 2019 - 2024. All rights reserved.