2017-06-14 1 views
0

je le script suivant:Gnuplot, l'amélioration de terrain fonction escalier

set xlabel "y" 
set ylabel "rw[j]" 
set title "P-D diagram" 
set xzeroaxis 
unset key 

plot [0.5:1] \ 
-5.71429*x title "L[-5]" linetype 1, \ 
-4.28571*x title "U[-5]" linetype 3, \ 
-4.71429*x title "L[-4]" linetype 1, \ 
-3.28571*x title "U[-4]" linetype 3, \ 
-3.71429*x title "L[-3]" linetype 1, \ 
-2.28571*x title "U[-3]" linetype 3, \ 
-2.71429*x title "L[-2]" linetype 1, \ 
-1.28571*x title "U[-2]" linetype 3, \ 
-1.71429*x title "L[-1]" linetype 1, \ 
-0.285714*x title "U[-1]" linetype 3, \ 
-0.714286*x title "L[0]" linetype 1, \ 
0.714286*x title "U[0]" linetype 3, \ 
0.285714*x title "L[1]" linetype 1, \ 
1.71429*x title "U[1]" linetype 3, \ 
1.28571*x title "L[2]" linetype 1, \ 
2.71429*x title "U[2]" linetype 3, \ 
2.28571*x title "L[3]" linetype 1, \ 
3.71429*x title "U[3]" linetype 3, \ 
3.28571*x title "L[4]" linetype 1, \ 
4.71429*x title "U[4]" linetype 3, \ 
4.28571*x title "L[5]" linetype 1, \ 
5.71429*x title "U[5]" linetype 3, \ 
(0.500000<= x && x <= 0.531250) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.531250<= x && x <= 0.562500) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.562500<= x && x <= 0.593750) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.593750<= x && x <= 0.625000) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.625000<= x && x <= 0.656250) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.656250<= x && x <= 0.687500) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.687500<= x && x <= 0.718750) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.718750<= x && x <= 0.750000) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.750000<= x && x <= 0.781250) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.781250<= x && x <= 0.812500) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.812500<= x && x <= 0.843750) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.843750<= x && x <= 0.875000) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.875000<= x && x <= 0.906250) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.906250<= x && x <= 0.937500) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.937500<= x && x <= 0.968750) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.968750<= x && x <= 1.000000) ? 0.000000:1.0/0.0 linetype 4,\ 
(0.500000<= x && x <= 0.531250) ? -2.312500:1.0/0.0 linetype 4,\ 
(0.531250<= x && x <= 0.562500) ? -2.500000:1.0/0.0 linetype 4,\ 
(0.562500<= x && x <= 0.593750) ? -2.625000:1.0/0.0 linetype 4,\ 
(0.593750<= x && x <= 0.625000) ? -2.750000:1.0/0.0 linetype 4,\ 
(0.625000<= x && x <= 0.656250) ? -2.937500:1.0/0.0 linetype 4,\ 
(0.656250<= x && x <= 0.687500) ? -3.062500:1.0/0.0 linetype 4,\ 
(0.687500<= x && x <= 0.718750) ? -3.187500:1.0/0.0 linetype 4,\ 
(0.718750<= x && x <= 0.750000) ? -3.375000:1.0/0.0 linetype 4,\ 
(0.750000<= x && x <= 0.781250) ? -3.500000:1.0/0.0 linetype 4,\ 
(0.781250<= x && x <= 0.812500) ? -3.625000:1.0/0.0 linetype 4,\ 
(0.812500<= x && x <= 0.843750) ? -3.812500:1.0/0.0 linetype 4,\ 
(0.843750<= x && x <= 0.875000) ? -3.937500:1.0/0.0 linetype 4,\ 
(0.875000<= x && x <= 0.906250) ? -4.125000:1.0/0.0 linetype 4,\ 
(0.906250<= x && x <= 0.937500) ? -4.250000:1.0/0.0 linetype 4,\ 
(0.937500<= x && x <= 0.968750) ? -4.375000:1.0/0.0 linetype 4,\ 
(0.968750<= x && x <= 1.000000) ? -4.562500:1.0/0.0 linetype 4,\ 
(0.500000<= x && x <= 0.531250) ? -1.812500:1.0/0.0 linetype 4,\ 
(0.531250<= x && x <= 0.562500) ? -1.937500:1.0/0.0 linetype 4,\ 
(0.562500<= x && x <= 0.593750) ? -2.062500:1.0/0.0 linetype 4,\ 
(0.593750<= x && x <= 0.625000) ? -2.187500:1.0/0.0 linetype 4,\ 
(0.625000<= x && x <= 0.656250) ? -2.312500:1.0/0.0 linetype 4,\ 
(0.656250<= x && x <= 0.687500) ? -2.437500:1.0/0.0 linetype 4,\ 
(0.687500<= x && x <= 0.718750) ? -2.500000:1.0/0.0 linetype 4,\ 
(0.718750<= x && x <= 0.750000) ? -2.625000:1.0/0.0 linetype 4,\ 
(0.750000<= x && x <= 0.781250) ? -2.750000:1.0/0.0 linetype 4,\ 
(0.781250<= x && x <= 0.812500) ? -2.875000:1.0/0.0 linetype 4,\ 
(0.812500<= x && x <= 0.843750) ? -3.000000:1.0/0.0 linetype 4,\ 
(0.843750<= x && x <= 0.875000) ? -3.125000:1.0/0.0 linetype 4,\ 
(0.875000<= x && x <= 0.906250) ? -3.250000:1.0/0.0 linetype 4,\ 
(0.906250<= x && x <= 0.937500) ? -3.312500:1.0/0.0 linetype 4,\ 
(0.937500<= x && x <= 0.968750) ? -3.437500:1.0/0.0 linetype 4,\ 
(0.968750<= x && x <= 1.000000) ? -3.562500:1.0/0.0 linetype 4,\ 
(0.500000<= x && x <= 0.531250) ? -1.312500:1.0/0.0 linetype 4,\ 
(0.531250<= x && x <= 0.562500) ? -1.437500:1.0/0.0 linetype 4,\ 
(0.562500<= x && x <= 0.593750) ? -1.500000:1.0/0.0 linetype 4,\ 
(0.593750<= x && x <= 0.625000) ? -1.562500:1.0/0.0 linetype 4,\ 
(0.625000<= x && x <= 0.656250) ? -1.687500:1.0/0.0 linetype 4,\ 
(0.656250<= x && x <= 0.687500) ? -1.750000:1.0/0.0 linetype 4,\ 
(0.687500<= x && x <= 0.718750) ? -1.812500:1.0/0.0 linetype 4,\ 
(0.718750<= x && x <= 0.750000) ? -1.937500:1.0/0.0 linetype 4,\ 
(0.750000<= x && x <= 0.781250) ? -2.000000:1.0/0.0 linetype 4,\ 
(0.781250<= x && x <= 0.812500) ? -2.062500:1.0/0.0 linetype 4,\ 
(0.812500<= x && x <= 0.843750) ? -2.187500:1.0/0.0 linetype 4,\ 
(0.843750<= x && x <= 0.875000) ? -2.250000:1.0/0.0 linetype 4,\ 
(0.875000<= x && x <= 0.906250) ? -2.375000:1.0/0.0 linetype 4,\ 
(0.906250<= x && x <= 0.937500) ? -2.437500:1.0/0.0 linetype 4,\ 
(0.937500<= x && x <= 0.968750) ? -2.500000:1.0/0.0 linetype 4,\ 
(0.968750<= x && x <= 1.000000) ? -2.625000:1.0/0.0 linetype 4,\ 
(0.500000<= x && x <= 0.531250) ? -0.812500:1.0/0.0 linetype 4,\ 
(0.531250<= x && x <= 0.562500) ? -0.875000:1.0/0.0 linetype 4,\ 
(0.562500<= x && x <= 0.593750) ? -0.937500:1.0/0.0 linetype 4,\ 
(0.593750<= x && x <= 0.625000) ? -1.000000:1.0/0.0 linetype 4,\ 
(0.625000<= x && x <= 0.656250) ? -1.062500:1.0/0.0 linetype 4,\ 
(0.656250<= x && x <= 0.687500) ? -1.125000:1.0/0.0 linetype 4,\ 
(0.687500<= x && x <= 0.718750) ? -1.125000:1.0/0.0 linetype 4,\ 
(0.718750<= x && x <= 0.750000) ? -1.187500:1.0/0.0 linetype 4,\ 
(0.750000<= x && x <= 0.781250) ? -1.250000:1.0/0.0 linetype 4,\ 
(0.781250<= x && x <= 0.812500) ? -1.312500:1.0/0.0 linetype 4,\ 
(0.812500<= x && x <= 0.843750) ? -1.375000:1.0/0.0 linetype 4,\ 
(0.843750<= x && x <= 0.875000) ? -1.437500:1.0/0.0 linetype 4,\ 
(0.875000<= x && x <= 0.906250) ? -1.500000:1.0/0.0 linetype 4,\ 
(0.906250<= x && x <= 0.937500) ? -1.500000:1.0/0.0 linetype 4,\ 
(0.937500<= x && x <= 0.968750) ? -1.562500:1.0/0.0 linetype 4,\ 
(0.968750<= x && x <= 1.000000) ? -1.625000:1.0/0.0 linetype 4,\ 
(0.500000<= x && x <= 0.531250) ? -0.312500:1.0/0.0 linetype 4,\ 
(0.531250<= x && x <= 0.562500) ? -0.375000:1.0/0.0 linetype 4,\ 
(0.562500<= x && x <= 0.593750) ? -0.375000:1.0/0.0 linetype 4,\ 
(0.593750<= x && x <= 0.625000) ? -0.375000:1.0/0.0 linetype 4,\ 
(0.625000<= x && x <= 0.656250) ? -0.437500:1.0/0.0 linetype 4,\ 
(0.656250<= x && x <= 0.687500) ? -0.437500:1.0/0.0 linetype 4,\ 
(0.687500<= x && x <= 0.718750) ? -0.437500:1.0/0.0 linetype 4,\ 
(0.718750<= x && x <= 0.750000) ? -0.500000:1.0/0.0 linetype 4,\ 
(0.750000<= x && x <= 0.781250) ? -0.500000:1.0/0.0 linetype 4,\ 
(0.781250<= x && x <= 0.812500) ? -0.500000:1.0/0.0 linetype 4,\ 
(0.812500<= x && x <= 0.843750) ? -0.562500:1.0/0.0 linetype 4,\ 
(0.843750<= x && x <= 0.875000) ? -0.562500:1.0/0.0 linetype 4,\ 
(0.875000<= x && x <= 0.906250) ? -0.625000:1.0/0.0 linetype 4,\ 
(0.906250<= x && x <= 0.937500) ? -0.625000:1.0/0.0 linetype 4,\ 
(0.937500<= x && x <= 0.968750) ? -0.625000:1.0/0.0 linetype 4,\ 
(0.968750<= x && x <= 1.000000) ? -0.687500:1.0/0.0 linetype 4,\ 
(0.500000<= x && x <= 0.531250) ? 0.312500:1.0/0.0 linetype 4,\ 
(0.531250<= x && x <= 0.562500) ? 0.375000:1.0/0.0 linetype 4,\ 
(0.562500<= x && x <= 0.593750) ? 0.375000:1.0/0.0 linetype 4,\ 
(0.593750<= x && x <= 0.625000) ? 0.375000:1.0/0.0 linetype 4,\ 
(0.625000<= x && x <= 0.656250) ? 0.437500:1.0/0.0 linetype 4,\ 
(0.656250<= x && x <= 0.687500) ? 0.437500:1.0/0.0 linetype 4,\ 
(0.687500<= x && x <= 0.718750) ? 0.437500:1.0/0.0 linetype 4,\ 
(0.718750<= x && x <= 0.750000) ? 0.500000:1.0/0.0 linetype 4,\ 
(0.750000<= x && x <= 0.781250) ? 0.500000:1.0/0.0 linetype 4,\ 
(0.781250<= x && x <= 0.812500) ? 0.500000:1.0/0.0 linetype 4,\ 
(0.812500<= x && x <= 0.843750) ? 0.562500:1.0/0.0 linetype 4,\ 
(0.843750<= x && x <= 0.875000) ? 0.562500:1.0/0.0 linetype 4,\ 
(0.875000<= x && x <= 0.906250) ? 0.625000:1.0/0.0 linetype 4,\ 
(0.906250<= x && x <= 0.937500) ? 0.625000:1.0/0.0 linetype 4,\ 
(0.937500<= x && x <= 0.968750) ? 0.625000:1.0/0.0 linetype 4,\ 
(0.968750<= x && x <= 1.000000) ? 0.687500:1.0/0.0 linetype 4,\ 
(0.500000<= x && x <= 0.531250) ? 0.812500:1.0/0.0 linetype 4,\ 
(0.531250<= x && x <= 0.562500) ? 0.875000:1.0/0.0 linetype 4,\ 
(0.562500<= x && x <= 0.593750) ? 0.937500:1.0/0.0 linetype 4,\ 
(0.593750<= x && x <= 0.625000) ? 1.000000:1.0/0.0 linetype 4,\ 
(0.625000<= x && x <= 0.656250) ? 1.062500:1.0/0.0 linetype 4,\ 
(0.656250<= x && x <= 0.687500) ? 1.125000:1.0/0.0 linetype 4,\ 
(0.687500<= x && x <= 0.718750) ? 1.125000:1.0/0.0 linetype 4,\ 
(0.718750<= x && x <= 0.750000) ? 1.187500:1.0/0.0 linetype 4,\ 
(0.750000<= x && x <= 0.781250) ? 1.250000:1.0/0.0 linetype 4,\ 
(0.781250<= x && x <= 0.812500) ? 1.312500:1.0/0.0 linetype 4,\ 
(0.812500<= x && x <= 0.843750) ? 1.375000:1.0/0.0 linetype 4,\ 
(0.843750<= x && x <= 0.875000) ? 1.437500:1.0/0.0 linetype 4,\ 
(0.875000<= x && x <= 0.906250) ? 1.500000:1.0/0.0 linetype 4,\ 
(0.906250<= x && x <= 0.937500) ? 1.500000:1.0/0.0 linetype 4,\ 
(0.937500<= x && x <= 0.968750) ? 1.562500:1.0/0.0 linetype 4,\ 
(0.968750<= x && x <= 1.000000) ? 1.625000:1.0/0.0 linetype 4,\ 
(0.500000<= x && x <= 0.531250) ? 1.312500:1.0/0.0 linetype 4,\ 
(0.531250<= x && x <= 0.562500) ? 1.437500:1.0/0.0 linetype 4,\ 
(0.562500<= x && x <= 0.593750) ? 1.500000:1.0/0.0 linetype 4,\ 
(0.593750<= x && x <= 0.625000) ? 1.562500:1.0/0.0 linetype 4,\ 
(0.625000<= x && x <= 0.656250) ? 1.687500:1.0/0.0 linetype 4,\ 
(0.656250<= x && x <= 0.687500) ? 1.750000:1.0/0.0 linetype 4,\ 
(0.687500<= x && x <= 0.718750) ? 1.812500:1.0/0.0 linetype 4,\ 
(0.718750<= x && x <= 0.750000) ? 1.937500:1.0/0.0 linetype 4,\ 
(0.750000<= x && x <= 0.781250) ? 2.000000:1.0/0.0 linetype 4,\ 
(0.781250<= x && x <= 0.812500) ? 2.062500:1.0/0.0 linetype 4,\ 
(0.812500<= x && x <= 0.843750) ? 2.187500:1.0/0.0 linetype 4,\ 
(0.843750<= x && x <= 0.875000) ? 2.250000:1.0/0.0 linetype 4,\ 
(0.875000<= x && x <= 0.906250) ? 2.375000:1.0/0.0 linetype 4,\ 
(0.906250<= x && x <= 0.937500) ? 2.437500:1.0/0.0 linetype 4,\ 
(0.937500<= x && x <= 0.968750) ? 2.500000:1.0/0.0 linetype 4,\ 
(0.968750<= x && x <= 1.000000) ? 2.625000:1.0/0.0 linetype 4,\ 
(0.500000<= x && x <= 0.531250) ? 1.812500:1.0/0.0 linetype 4,\ 
(0.531250<= x && x <= 0.562500) ? 1.937500:1.0/0.0 linetype 4,\ 
(0.562500<= x && x <= 0.593750) ? 2.062500:1.0/0.0 linetype 4,\ 
(0.593750<= x && x <= 0.625000) ? 2.187500:1.0/0.0 linetype 4,\ 
(0.625000<= x && x <= 0.656250) ? 2.312500:1.0/0.0 linetype 4,\ 
(0.656250<= x && x <= 0.687500) ? 2.437500:1.0/0.0 linetype 4,\ 
(0.687500<= x && x <= 0.718750) ? 2.500000:1.0/0.0 linetype 4,\ 
(0.718750<= x && x <= 0.750000) ? 2.625000:1.0/0.0 linetype 4,\ 
(0.750000<= x && x <= 0.781250) ? 2.750000:1.0/0.0 linetype 4,\ 
(0.781250<= x && x <= 0.812500) ? 2.875000:1.0/0.0 linetype 4,\ 
(0.812500<= x && x <= 0.843750) ? 3.000000:1.0/0.0 linetype 4,\ 
(0.843750<= x && x <= 0.875000) ? 3.125000:1.0/0.0 linetype 4,\ 
(0.875000<= x && x <= 0.906250) ? 3.250000:1.0/0.0 linetype 4,\ 
(0.906250<= x && x <= 0.937500) ? 3.312500:1.0/0.0 linetype 4,\ 
(0.937500<= x && x <= 0.968750) ? 3.437500:1.0/0.0 linetype 4,\ 
(0.968750<= x && x <= 1.000000) ? 3.562500:1.0/0.0 linetype 4,\ 
(0.500000<= x && x <= 0.531250) ? 2.312500:1.0/0.0 linetype 4,\ 
(0.531250<= x && x <= 0.562500) ? 2.500000:1.0/0.0 linetype 4,\ 
(0.562500<= x && x <= 0.593750) ? 2.625000:1.0/0.0 linetype 4,\ 
(0.593750<= x && x <= 0.625000) ? 2.750000:1.0/0.0 linetype 4,\ 
(0.625000<= x && x <= 0.656250) ? 2.937500:1.0/0.0 linetype 4,\ 
(0.656250<= x && x <= 0.687500) ? 3.062500:1.0/0.0 linetype 4,\ 
(0.687500<= x && x <= 0.718750) ? 3.187500:1.0/0.0 linetype 4,\ 
(0.718750<= x && x <= 0.750000) ? 3.375000:1.0/0.0 linetype 4,\ 
(0.750000<= x && x <= 0.781250) ? 3.500000:1.0/0.0 linetype 4,\ 
(0.781250<= x && x <= 0.812500) ? 3.625000:1.0/0.0 linetype 4,\ 
(0.812500<= x && x <= 0.843750) ? 3.812500:1.0/0.0 linetype 4,\ 
(0.843750<= x && x <= 0.875000) ? 3.937500:1.0/0.0 linetype 4,\ 
(0.875000<= x && x <= 0.906250) ? 4.125000:1.0/0.0 linetype 4,\ 
(0.906250<= x && x <= 0.937500) ? 4.250000:1.0/0.0 linetype 4,\ 
(0.937500<= x && x <= 0.968750) ? 4.375000:1.0/0.0 linetype 4,\ 
(0.968750<= x && x <= 1.000000) ? 4.562500:1.0/0.0 linetype 4 
pause - 1 

qui trace les éléments suivants: enter image description here

Je voudrais être en mesure de tracer un escalier réelle au lieu de ces sauts, aussi Il me semble que deux lignes orange consécutives dans l'axe des y, il y a un écart delta_y, mais il ne devrait pas être comme cela étant donné que l'axe y est partitionné en intervalles contigus.

Des indices? (PS le script est généré par un programme, ma version gnuplot est 5.2)

+1

Enregistrez vos données d'escalier dans un fichier et utilisez le style de tracé 'steps',' histeps'. – Christoph

+0

Pouvez-vous donner un exemple? – user8469759

+0

http://gnuplot.sourceforge.net/demo_5.0/steps.html – Christoph

Répondre

1

Vous pouvez utiliser la fonction int pour arrondir les nombres (positifs) à l'entier suivant. En utilisant les bons facteurs, cela donne des mesures appropriées. Par exemple, vous pouvez faire ce qui suit pour tracer 5*x dans les étapes de la taille 0.31250:

rounddown(x,p) = int(x/p)*p 
plot rounddown(5*x,0.31250) 

Notez que pour les basses résolutions, il peut être nécessaire d'augmenter le nombre d'échantillons, par exemple comme suit:

set samples 10000