Search code examples
plotrangegnuplotaxisxrange

gnuplot - How do I change xrange when changing x-axis scale?º


I have the following data:

100 100.0
500 499.8
1000 999.0
2000 1994.4
3000 2918.8
10000 8233.8
99999 9433.2

I want to plot this so I have all x-axis labels equally spaced. Taking this link into account, I made the following script:

set terminal png size 500,500

set output 'throughput.png'
set title 'Connection throughput'

plot 'throughput.txt' using 0:2:xticlabel(1) title "Throughput"

I get the following.

image.

Nonetheless, I want the data points from 100 and 99999 values to be visible. To solve it I tried using the set xrange [0,110000] instruction. The result this.

this.

As you can see, x-axis is messed up.

My questions are, what is causing this to happen? Is there any other way to set the x-axis range?

Thanks for any help in advance.


Solution

  • Your data points from 100 and 99999 are visible. These violet +s are just on top of the axes and hardly visible.

    Two possible options:

    • change the pointtype and color to make the data points "visible"

    • add an offset (or margin) to your graph (check help offsets)

    Also possible: set offsets 0.5, 0.5, 0.0, 0.0

    Script:

    ### change pointtype and add margins
    reset session
    
    $Data <<EOD
    100 100.0
    500 499.8
    1000 999.0
    2000 1994.4
    3000 2918.8
    10000 8233.8
    99999 9433.2
    EOD
    
    set key top left
    set offsets graph 0.05, graph 0.05, graph 0.05, graph 0.00   # left, right, top, bottom
    
    plot $Data u 0:2:xtic(1) w points pt 7 lc "red" ti "Throughput"
    ### end of script
    

    Result:

    enter image description here