1

I am trying to populate graph with some fixed values on X-axis and corresponding values on Y-axis. With my below script, no values are labelled on X-axis and value on Y-axis are labelled with powers.

  1. How to make xtics data(1000, 10000, 100000, 1000000, 10000000) appear on X-axis ?
  2. How to get rid of powers on Y-axis ? (Example : I want 4000000 on Y-axis instead of 4x10^6

    set xrange [0:]
    set output "macs.png"
    set ylabel "Flows/sec"
    set xlabel  "MACS per Switch"
    set grid
    set xtics (1000, 10000, 100000, 1000000, 10000000)
    set style line 2 lt 1 lw 2 pt 1 linecolor 1
    plot "macs.data" using :1 with linespoints linestyle 0 title "Floodlight" // Using ":1" as X-axis data is supplied in xtics
    

Here is my data file :

# Not Supplying X-axis data here as it is supplied through xtics
400
60000
700000
800000
900000

I want my populated graph with only one line to looks like this :enter image description here

Anil Kumar K K
  • 1,395
  • 1
  • 16
  • 27

1 Answers1

3

You have supply x and y value for each point. Fortunately, gnuplot supports some special column numbers like column 0, which is a counter of valid data sets, i.e. here a line number ignoring comments. It starts at zero.

Next, your x-axis uses a log scale, so you should do it, too. The formula to convert line number to correct x-value is 10(colum_0) + 3. which translates to 10**($0+3) in gnuplot.

Here is the code:

# Logarithmic scale for x axis
set log x


# get rid of scientific formatting of numbers,
# plain format also for large numbers
set format x "%.0f"

# If you don't like the small ticks between the large ones
set mxtics 1

# put the key (legend) outside, right of the plot area, 
# vertically centered (as in your picture)
set key outside right center


# only horizontal grid lines
set grid y   


plot "macs.data" using (10**($0+3)):1 title "foo" with linespoints

And here the result:

enter image description here


Alternative:

Your approach plots the data as if it were given like

0   400
1  60000
2 700000
3 800000
4 900000

In this case, you need to label the x-axis on your own, the correct syntax is

set xtics("1000" 0, "10000" 1, "100000" 2, "1000000" 3, "10000000" 4)

This will not draw any automatic labels, but it will put e.g. your string 10000 at x=1

sweber
  • 2,916
  • 2
  • 15
  • 22
  • If I set the xtics using set xtics("1000" 0, "10000" 1, "100000" 2, "1000000" 3, "10000000" 4), Do I need to specify column number for X-axis in plot ? (Example : _plot "macs.data" using :2 title "foo" with linespoints_ Is it fine ? ) – Anil Kumar K K Apr 25 '15 at 18:05
  • if you don't give a number, gnuplot uses the default. So `using :2` should be an equivalent to `using 1:2`. But your data has only one column, so you should use `using 0:1`. As said, the `0` is a special column. – sweber Apr 25 '15 at 18:25