Инвертировать / инвертировать накопительный gnuplot - PullRequest
0 голосов
/ 05 мая 2020

Я могу построить кумулятивный график, используя этот входной файл:

set key top left
set xtics font 'Arial,18'
set terminal pdf solid font 'Arial,18' # pdf files are great for inkscape
set output 'cumulative.pdf'

unset xtics; unset ytics # Remove all tics
set ytics nomirror # Only have tics on left
set xtics nomirror # Only have tics on bottom
set border 3 # Only have border on bottom and left

set xrange [50:170]
#set yrange [0:10000]
set xtics 50,10,170
#set ytics 0,20,100
set tics out nomirror


plot "1.3SLN-all.txt" using 1:(.0000401) smooth cumul title "1.3SLN", \
"1.6SLN-all.txt" using 1:(.0000401) smooth cumul title "1.6SLN", \
"2.3SDLN-all.txt" using 1:(.0000401) smooth cumul title "2.3SDLN", \
"2.6SDLN-all.txt" using 1:(.0000401) smooth cumul title "2.6SDLN", \
"3.3STLN-all.txt" using 1:(.0000401) smooth cumul title "3.3STLN", \
"3.6STLN-all.txt" using 1:(.0000401) smooth cumul title "3.6STLN"

Это дает следующий график:

Cumulative plot produced by code

Файлы данных выглядят следующим образом:

52.712
52.246
52.391
53.814
52.260
57.365
58.331
53.628
55.391
55.422

et c

Я хочу инвертировать его, чтобы оно накапливалось от наибольшего числа к наименьшему. Примерно так:

Inverted cumulative

Который я редактировал. Я думал сделать все свои числа отрицательными, а затем отредактировать ось позже, но это не очень меня устраивало.

1 Ответ

0 голосов
/ 05 мая 2020

Если я правильно понял ваш вопрос. Попробуйте следующий пример и адаптируйте его к своим потребностям:

  1. поместите ваши файлы в блоки данных, используя smooth frequency. Отметьте help smooth frequency.
  2. поменять местами блоки данных
  3. накапливать блоки данных «вручную»

Вероятно, есть способ без записи перевернутых и накопленных данных в файл , либо с использованием дополнительных блоков данных или массивов.

Код:

### reverse cumulative plot
reset session

FILES = 'One Two Three Four Five Six'
FileCount = words(FILES)
File(i) = sprintf("%s-all.txt",word(FILES,i))

# create some random test data
do for [i=1:FileCount] {
    set samples int(rand(0)*500)+100
    set table File(i)
        offset = rand(0)*5+4
        plot '+' u (invnorm(rand(0))+offset) w table
    unset table
}

# smooth, reverse, cumulate data 
do for [i=1:FileCount] {
    # smooth file data into datablock
    set table $Data
        plot [][0:1] File(i) u 1:(4.01e-5) smooth frequency
    unset table

    # reverse the datablock
    set print $DataR
        do for [j=|$Data|:1:-1] {
            print $Data[j]
        }
    set print

    # cumulate the reversed datablock into file
    set table File(i)."_RC.dat"
        plot c=0 $DataR u 1:(c=c+$2) w table
    unset table
}

set yrange[-0.002:]
set multiplot layout 2,1

    set title "cumulative" 
    set key top left
    plot for [i=1:FileCount] File(i) u 1:(4.01e-5) smooth cumulative w l lw 2 ti File(i) noenhanced

    set title "reverse cumulative"
    set key top right
    plot for [i=1:FileCount] File(i)."_RC.dat" u 1:2 w l ti File(i) lw 2 noenhanced

unset multiplot
### end of code

Результат:

enter image description here

...