2014-02-05 80 views
1

我試圖用GNUPLOT製作這個直方圖,但我無法理解如何顯示國家的名稱(我也放了我的dati.dat文件)。在直方圖中改變Y軸的距離GNUPLOT

下面的代碼:

reset 

set terminal pngcairo size 500,500 enhanced font 'Verdana,10' 
set output 'Err_rev.png' 

# this command to modify the orientation of the png 
#convert -rotate 90 Err_rev.png Err_rev_out.png 

set key at graph 0.24, 0.80 horizontal samplen 0.1 
set style data histogram 
set style histogram cluster gap 2 
set style fill solid border -1 
set boxwidth 0.8 
set xtic rotate by 90 scale 0 
unset ytics 
set y2tics rotate by 90 
set yrange [0:100]; set xrange [*:*] 
set y2label 'Paragone tra Nazioni: Domicilio - Hospice ' offset -2.5 
set xlabel ' ' 
set size 1, 0.96 
set label 1 'Nazioni' at graph 0.5, -0.1 centre rotate by 180 
set label 2 'Domicilio' at graph 0.135, 0.83 left rotate by 90 
set label 3 'Hospice' at graph 0.21, 0.83 left rotate by 90 
p 'dati.dat' u 2 title ' ', '' u ($2/2.0+rand(0)/10.0) title ' ', '' u 0:(0):xticlabel(1) w l title '' 

而這裏FILE.DAT:

Inghilterra 63 29 
Belgio 71.6 9.9 
Germania 66 14.8 
Olanda 83.1 10.5 
Portogallo 50.1 35.7 
Spagna 60.1 16.8 
Italia 76.1 12 

非常感謝。

回答

1

要設置xtic標籤,您可以在第一個命令中使用using 2:xtic(1)。要正確查看標籤,必須將xtics的對齊方式設置爲right

而且您可以包含轉換命令以在腳本內旋轉繪圖。用system來稱呼它。在此之前,您必須使用set output而沒有文件名來表明文件必須被刷新並關閉。

更改後的腳本是:

reset 

set terminal pngcairo size 500,500 enhanced font 'Verdana,10' 
set output 'Err_rev.png' 

set key at graph 0.24, 0.80 horizontal samplen 0.1 
set style data histogram 
set style histogram cluster gap 2 
set style fill solid border -1 
set boxwidth 0.8 
set xtic rotate by 90 scale 0 right 
unset ytics 
set y2tics center rotate by 90 
set yrange [0:100]; set xrange [*:*] 
set y2label 'Paragone tra Nazioni: Domicilio - Hospice ' offset -2.5 
set size 1, 0.96 
set label 1 'Nazioni' at graph 0.5, char 1 centre rotate by 180 
set label 2 'Domicilio' at graph 0.135, 0.83 left rotate by 90 
set label 3 'Hospice' at graph 0.21, 0.83 left rotate by 90 

plot 'dati.dat' u 2:xtic(1) title ' ', '' u ($2/2.0+rand(0)/10.0) title ' ' 

set output 
# this command to modify the orientation of the png 
system('convert -rotate 90 Err_rev.png Err_rev_out.png') 

,結果Err_rev_out.png(與4.6.3版本):

enter image description here

的另一種方法來繪製水平直方圖與boxxyerrorbars風格,這也需要一些,但其他技巧。 Gnuplot interchanging Axes