Menu

Change x axis scale

2020-10-26
2020-10-27
  • André Ricardo Saraiva

    I'm trying to change the scale of the x-axis linearly, that is, that the distance between the points was proportional, so I have two points (12.23 and 12.12) that should be glued together and others like 19.35 with 23, 8 that should be well spaced and 23.8 to 24.7 that should be closer, but I was not able to do this correctly

     reset
    set encoding iso_8859_1
    set key fixed right top vertical Right noreverse noenhanced autotitle nobox
    set style increment default
    set datafile missing '-'
    set style data linespoints
    set xtics border in scale 1,0.5 nomirror rotate by -45 # autojustify
    set xtics  norangelimit 
    set xtics ()
    set log x
    set key center top inside
    set title "DC 5,86%" 
    set xrange [ * : * ] noreverse writeback
    set x2range [ * : * ] noreverse writeback
    set yrange [ * : * ] noreverse writeback
    set y2range [ * : * ] noreverse writeback
    set zrange [ * : * ] noreverse writeback
    set cbrange [ * : * ] noreverse writeback
    set rrange [ * : * ] noreverse writeback
    
    plot 'teste2.dat' using 2:xtic(1) title columnheader(2),'teste2.dat' using 3:xtic(1) title columnheader(3) ``
    

    my test2.dat is

     DC      L=1    L>1
    42.85   15.98   -
    32.5        -   26.09
    30.76   23.12   -
    24.7        -   31.75
    23.8    33.1    -
    19.35   42.11   -
    14.03   61.72   -
    12.23   62.65   -
    12.12       -   75.38
    10.98   44.58   -
    

    I'm trying to change the scale of the x-axis linearly, that is, that the distance between the points was proportional, so I have two points (12.23 and 12.12) that should be glued together and others like 19.35 with 23, 8 that should be well spaced and 23.8 to 24.7 that should be closer, but I was not able to do this correctly.

    reset
    set encoding iso_8859_1
    set key fixed right top vertical Right noreverse noenhanced autotitle nobox
    set style increment default
    set datafile missing '-'
    set style data linespoints
    set xtics border in scale 1,0.5 nomirror rotate by -45 # autojustify
    set xtics norangelimit
    set xtics ()
    set log x
    set key center top inside
    set title "DC 5,86%"
    set xrange [ * : * ] noreverse writeback
    set x2range [ * : * ] noreverse writeback
    set yrange [ * : * ] noreverse writeback
    set y2range [ * : * ] noreverse writeback
    set zrange [ * : * ] noreverse writeback
    set cbrange [ * : * ] noreverse writeback
    set rrange [ * : * ] noreverse writeback

    plot 'teste2.dat' using 2:xtic(1) title columnheader(2),'teste2.dat' using 3:xtic(1) title columnheader(3)
    my test2.dat is

    DC      L=1    L>1
    

    42.85 15.98 -
    32.5 - 26.09
    30.76 23.12 -
    24.7 - 31.75
    23.8 33.1 -
    19.35 42.11 -
    14.03 61.72 -
    12.23 62.65 -
    12.12 - 75.38
    10.98 44.58 -
    I've been trying to do this for some time. Could someone help me with this function?

     
  • Hans-Bernhard Broeker

    The core problem is that your script is trying quite hard to make gnuplot do the exact opposite of what you say you want it to do. The whole point of the xticlabels() feature is to do what say you don't want: ignore the numbers, and just treat them as strings. So don't use that.

    [Oh and there was no need to YELL AT PEOPLE in the subject line. I fixed that.]

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.