1

我有以下图表:

  • 第一个数据集显示搜索。
  • 第二个数据集显示点击。

y1显示搜索比例,y2显示点击比例。在x1我有时间值显示。

x2我希望在(上轴)上显示点击值(每小时)。当我添加命令set x2tics时,它会显示搜索数据,而不是我希望的点击。

如何更改它以显示点击单位?

Gnuplot 脚本:

set xlabel "Time"
set ylabel "Times"
set y2range [0:55000]
set y2tics 0, 1000
set ytics nomirror
set datafile separator "|"
set title "History of searches"
set xdata time          # The x axis data is time
set timefmt "%Y-%m-%d %H:%M"        # The dates in the file look like 10-Jun-04
set format x "%d/%m\n%H:%M"
set grid
set terminal png size 1024,768        # gnuplot recommends setting terminal before output
set output "outputFILE.png"  # The output filename; to be set after setting
                     # terminal
load "labelsFILE"

plot 'goodFILE' using 1:3 lt 2 with lines t 'Success'  , 'clicksFILE' using 1:2 lt 5 with lines t 'Clicks right Y' axis x1y2


replot

图形:

图 http://img42.imageshack.us/img42/1269/wu0b.png

4

1 回答 1

1

好的,所以要开始,这里是如何设置一个带有点击次数的标签,如下所示(使用你的数据文件名):

plot 'goodFILE' using 1:3 lt 2 with lines t 'Success',\
     'clicksFILE' using 1:2 lt 5 with lines t 'Clicks right Y' axis x1y2,\
     '' using 1:2:(sprintf("%dk", int($2/1000.0))) with labels axis x1y2 offset 0,1 t ''

只需将其添加为绘图命令,它应该可以正常工作。

为了说明标签的外观,下面是一个带有一些虚拟数据的示例:

set terminal pngcairo
set output 'blubb.png'

set xlabel "Time"
set ylabel "Times"
set y2label "Clicks per hour"
set y2range [0:10000]
set yrange [0:1]
set ytics nomirror
set y2tics
set key left

set samples 11
set xrange[0:10000]
plot '+' using 1:1:(sprintf("%dk", int($1/1000.0))) every ::1::9 with labels axis x1y2 offset 0,1 t '',\
     '' using 1:1 with linespoints axis x1y2 pt 7 t 'Clicks per hour'

这给了你:

在此处输入图像描述

于 2013-08-28T09:25:30.593 回答