2015-04-25 167 views
0

我想用X軸上的一些固定值和Y軸上的相應值填充圖形。用我的下面的腳本,沒有值標記在X軸上,而Y軸上的值標有冪。gnuplot:xtics在X軸上沒有顯示

  1. 如何在X軸上顯示xtics數據(1000,10000,100000,1000000,10000000)?
  2. 如何擺脫Y軸的權力? (實施例:我想4000000在Y軸上,而不是4×10^6

    set xrange [0:] 
    set output "macs.png" 
    set ylabel "Flows/sec" 
    set xlabel "MACS per Switch" 
    set grid 
    set xtics (1000, 10000, 100000, 1000000, 10000000) 
    set style line 2 lt 1 lw 2 pt 1 linecolor 1 
    plot "macs.data" using :1 with linespoints linestyle 0 title "Floodlight" // Using ":1" as X-axis data is supplied in xtics 
    

這是我的數據文件:

# Not Supplying X-axis data here as it is supplied through xtics 
400 
60000 
700000 
800000 
900000 

我想只有一行到看起來像我的填充圖形這個:enter image description here

回答

2

你可以爲每個點提供x和y值幸運的是,gnuplot支持一些特殊的列號,比如第0列,這是一個有效數據集的計數器,這裏是一個忽略註釋的行號秒。它從零開始。

接下來,您的x軸使用對數刻度,所以您也應該這樣做。將行號轉換爲正確的x值的公式爲10 (colum_0)+ 3。在gnuplot中轉換爲10**($0+3)

下面是代碼:

# Logarithmic scale for x axis 
set log x 


# get rid of scientific formatting of numbers, 
# plain format also for large numbers 
set format x "%.0f" 

# If you don't like the small ticks between the large ones 
set mxtics 1 

# put the key (legend) outside, right of the plot area, 
# vertically centered (as in your picture) 
set key outside right center 


# only horizontal grid lines 
set grid y 


plot "macs.data" using (10**($0+3)):1 title "foo" with linespoints 

而且這裏的結果:

enter image description here


備選:

您的方法繪製,好像它是數據給出如

0 400 
1 60000 
2 700000 
3 800000 
4 900000 

在這種情況下,你需要標註在自己的x軸,正確的語法是

set xtics("1000" 0, "10000" 1, "100000" 2, "1000000" 3, "10000000" 4) 

這不會得出任何自動標籤,但是它會把例如你的字符串10000在x = 1

+0

如果我使用set xtics(「1000」0,「10000」1,「100000」2,「1000000」3,「10000000」4)設置xtics,我需要指定繪圖中X軸的列號? (例如:_plot「macs.data」使用:2標題「foo」與linespoints_是否好?) –

+0

如果你不給數字,gnuplot使用默認值。所以'使用:2'應該等同於'使用1:2'。但是你的數據只有一列,所以你應該使用'使用0:1'。如上所述,'0'是一個特殊的列。 – sweber