2013-06-26 60 views
2

我想繪製一條延伸超出軸極限的直線。我已經嘗試設置clipping屬性off這樣的:在Octave中顯示一條超出軸極限的直線

figure 
axis([0, 10, 0, 10]) 
hold on 
set(gca,'outerPosition',[0, 0.5, 1, 0.5]) 
lh = line([2, 8],[8, -5]); 
set(lh, 'clipping', 'off') 
print('line_plot.png') 

我得到一個數字,看起來像這樣:

plot with line that ends at the border of the axis

有沒有一種方法,使線超出X -軸?我正在使用gnuplot和AquaTerm。這可能會在另一個終端?

回答

2

在gnuplot中,我會建議註釋一個箭頭,它可以延伸到軸之外。這裏有一個小例子來實現你在你的問題概括什麼:

# define the location of your plot: 
bm = 0.15 
lm = 0.12 
rm = 0.95 
tm = 0.95 
set lmargin at screen lm 
set rmargin at screen rm 
set bmargin at screen bm 
set tmargin at screen tm 

# define your axis limits: 
xmax = 10.0    
xmin = 0.0 
ymax = 10.0     
ymin = 0.0     
set xrange [xmin:xmax] 
set yrange [ymin:ymax] 

# define you data points: 
xstart = 2 
ystart = 8 
xend = 8 
yend = -5 

# convert points into screen coordinates: 
dx_rel = (rm-lm)/(xmax-xmin) 
dy_rel = (tm-bm)/(ymax-ymin) 

xstart_rel = lm + dx_rel * xstart 
ystart_rel = bm + dy_rel * ystart 
xend_rel = lm + dx_rel * xend           
yend_rel = bm + dy_rel * yend 

# define 'arrow' without head in screen coordinates: 
set arrow 1 from screen xstart_rel,ystart_rel \ 
       to screen xend_rel,yend_rel nohead 

# plot will not show when empty, include dummy plot command: 
set parametric 
plot xstart, ystart not 

clip option你指的是gnuplot的不允許您擴展情節過去軸線。它旨在移除靠近軸的數據點以避免與這些軸重疊的符號。
然而,arrow可以指定在screen座標(屏幕在這種情況下是繪圖窗口),它允許您繪製軸外。
要匹配特定的數據座標,必須將其轉換爲屏幕座標。當您在這些屏幕座標中定義繪圖邊界時,這隻會可靠地工作。這樣,您可以計算每個數據點在屏幕上的位置。
當爲arrow時,請務必在座標前使用screen來指示正確的座標系。上述
腳本會給你這樣的情節:

enter image description here

+0

謝謝!那可行。 – Molly