Brzmi to jak chcesz, aby dane wyjściowe do dynamicznie dopasuj rozmiar do wykreślanych danych. Oto skrypt, który to robi:
#!/usr/bin/env gnuplot
# don't make any output just yet
set terminal unknown
# plot the data file to get information on ranges
plot 'data.dat' title 'My Moneys'
# span of data in x and y
xspan = GPVAL_DATA_X_MAX - GPVAL_DATA_X_MIN
yspan = GPVAL_DATA_Y_MAX - GPVAL_DATA_Y_MIN
# define the values in x and y you want to be one 'equivalent:'
# that is, xequiv units in x and yequiv units in y will make a square plot
xequiv = 100
yequiv = 250
# aspect ratio of plot
ar = yspan/xspan * xequiv/yequiv
# dimension of plot in x and y (pixels)
# for constant height make ydim constant
ydim = 200
xdim = 200/ar
# set the y tic interval
set ytics 100
# set the x and y ranges
set xrange [GPVAL_DATA_X_MIN:GPVAL_DATA_X_MAX]
set yrange [GPVAL_DATA_Y_MIN:GPVAL_DATA_Y_MAX]
# set the labels
set title 'Dollars in buckets'
set xlabel 'number'
set ylabel 'Dollars'
set terminal png size xdim,ydim
set output 'test.png'
set size ratio ar
set style data linespoints
replot
Dla tych przykładowych danych:
0 50
50 150
100 400
150 500
200 300
uzyskać następujące działki:
Chodzi o placu, jak powinno (zdefiniowałem 100 jednostek na x, aby były równe 250 jednostkom y, a dane mieszczą się w zakresie [(0,200), (50,500)]). Jeśli dodać kolejny punkt danych (400,300), plik wyjściowy jest szerszy, zgodnie z oczekiwaniami:
Aby odpowiedzieć na inne pytanie, można ustawić y tic przyrost sposób:
set ytics <INCREMENT>
Powyższy skrypt podaje przykład.
Nota boczna: określenie rozmiaru w poleceniu terminalu ('set terminal png size ...') definiuje rozmiar rzeczywistego pliku wyjściowego, a polecenie 'set size ratio' ustawia współczynnik kształtu obszaru w obrębie wyjścia gdzie jest naniesiony wykres. Zrobiłem oba, aby upewnić się, że proporcje będą spójne. –
andyras