1
votes

I have the following graph:

  • first data set display searches.
  • second data set display clicks.

y1 shows searches scale, y2 shows click scale. on the x1 I have time values displayed.

I wish to display clicks values (each hour) on x2 (the upper axis). When I add the command set x2tics it displays the searches data and not the clicks like I wished.

How do I change it so it will display the clicks unit?

Gnuplot script:

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

Graph:

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

1
I don't fully understand whats the problem. I would say use x2y2, instead of x1y2. But why do you want to plot the clicks against the x2-axis? Do you have a different timescale for them, or what? - Christoph
Hi, i wish to leave the date/time data on x1 and add to x2 tics for # of clicks per hour. i don't have a different timescale for the clicks. if i can add another tic data on the x1 it can be good also, just without hiding the date/time data. - dudu1982
I'm sorry, but I don't have an idea of what you really want. Do you maybe want to place a label with the number of clicks every hour, like it could be done with the labels plot style? - Christoph
I agree with Christoph. What additional information do you have for the 2nd x-axis? The way I understand your data is: you have x1=time, y1=searches; x2=time, y2=clicks - however, in your case x1=x2. - Schorsch
I agree that time is on x1,x2 but i wish to have clicks per hour sum on x1 or x2. maybe it's possible to put labels on the graph itself? for example, if between 20:00 and 21:00 i had 43K clicks i wish to have the exact number per hour labeled on the 21:00 point in x2. is that possible? if i add "set x2tics" at the begining of the script it does add the data for searches (per half an hour), can't that be changed to clicks? - dudu1982

1 Answers

1
votes

Ok, so to get started, here is how you can set a label with the number of clicks as follows (using you data file names):

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 ''

Just add this as plotting command, and it should work just fine.

To illustrate, how the labels might look like, here is an example with some dummy data:

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'

Which gives you:

enter image description here