grid.curve
位於 grid
包(package)。 說明
這些函數創建並繪製從一個位置到另一個位置的曲線。
用法
grid.curve(...)
curveGrob(x1, y1, x2, y2, default.units = "npc",
curvature = 1, angle = 90, ncp = 1, shape = 0.5,
square = TRUE, squareShape = 1,
inflect = FALSE, arrow = NULL, open = TRUE,
debug = FALSE,
name = NULL, gp = gpar(), vp = NULL)
arcCurvature(theta)
參數
x1 |
指定起始點 x-location 的數值向量或單位對象。 |
y1 |
指定起始點 y-location 的數值向量或單位對象。 |
x2 |
指定終點x-location的數值向量或單位對象。 |
y2 |
指定終點y-location的數值向量或單位對象。 |
default.units |
一個字符串,指示僅以數值形式給出 |
curvature |
給出曲率量的數值。負值產生左手曲線,正值產生右手曲線,零產生直線。 |
angle |
0 到 180 之間的數值,給出曲線控製點的傾斜量。小於 90 的值使曲線向起點傾斜,大於 90 的值使曲線向終點傾斜。 |
ncp |
用於繪製曲線的控製點的數量。更多控製點可創建更平滑的曲線。 |
shape |
由 -1 到 1 之間的值組成的數值向量,用於控製曲線相對於其控製點的形狀。有關更多詳細信息,請參閱 |
square |
控製是否以 city-block 方式或傾斜方式創建曲線控製點的邏輯值。當 |
squareShape |
|
inflect |
一個邏輯值,指定曲線是否應切成兩半並反轉(請參見下麵的示例)。 |
arrow |
說明放置在曲線兩端的箭頭的列表,由 |
open |
一個邏輯值,指示是否閉合曲線(連接起點和終點)。 |
debug |
指示是否應繪製調試信息的邏輯值。 |
name |
字符標識符。 |
gp |
類 |
vp |
網格視口對象(或 NULL)。 |
... |
要傳遞給 |
theta |
角度(以度為單位)。 |
細節
這兩個函數都創建一個曲線grob(說明曲線的圖形對象),但隻有grid.curve
繪製曲線。
arcCurvature
函數可用於計算curvature
,從而在與角度theta
對應的圓弧上生成控製點。這通常與大型 ncp
結合使用,以生成與所需弧線相對應的曲線。
值
一個抓取對象。
例子
curveTest <- function(i, j, ...) {
pushViewport(viewport(layout.pos.col=j, layout.pos.row=i))
do.call("grid.curve", c(list(x1=.25, y1=.25, x2=.75, y2=.75), list(...)))
grid.text(sub("list\\((.*)\\)", "\\1",
deparse(substitute(list(...)))),
y=unit(1, "npc"))
popViewport()
}
# grid.newpage()
pushViewport(plotViewport(c(0, 0, 1, 0),
layout=grid.layout(2, 1, heights=c(2, 1))))
pushViewport(viewport(layout.pos.row=1,
layout=grid.layout(3, 3, respect=TRUE)))
curveTest(1, 1)
curveTest(1, 2, inflect=TRUE)
curveTest(1, 3, angle=135)
curveTest(2, 1, arrow=arrow())
curveTest(2, 2, ncp=8)
curveTest(2, 3, shape=0)
curveTest(3, 1, curvature=-1)
curveTest(3, 2, square=FALSE)
curveTest(3, 3, debug=TRUE)
popViewport()
pushViewport(viewport(layout.pos.row=2,
layout=grid.layout(3, 3)))
curveTest(1, 1)
curveTest(1, 2, inflect=TRUE)
curveTest(1, 3, angle=135)
curveTest(2, 1, arrow=arrow())
curveTest(2, 2, ncp=8)
curveTest(2, 3, shape=0)
curveTest(3, 1, curvature=-1)
curveTest(3, 2, square=FALSE)
curveTest(3, 3, debug=TRUE)
popViewport(2)
也可以看看
相關用法
- R grid.copy 製作網格圖形對象的副本
- R grid.convert 不同網格坐標係之間的轉換
- R grid.clip 設置剪切區域
- R grid.cap 捕獲光柵圖像
- R grid.circle 畫一個圓
- R grid.draw 畫一個網格
- R grid.stroke 描邊或填充路徑
- R grid.raster 渲染光柵對象
- R grid.points 繪製數據符號
- R grid.force 強製將一個對象放入其組件中
- R grid.display.list 控製網格顯示列表
- R grid.show.viewport 繪製網格視口圖
- R grid.segments 繪製線段
- R grid.frame 創建用於包裝對象的框架
- R grid.group 畫一個組
- R grid.pack 將對象打包在框架內
- R grid.text 繪製文字
- R grid.xspline 繪製 X 樣條線
- R grid.record 封裝計算和繪圖
- R grid.pretty 生成一組合理(“漂亮”)的斷點
- R grid.grab 抓取當前電網輸出
- R grid.show.layout 繪製網格布局圖
- R grid.DLapply 修改網格顯示列表
- R grid.delay 封裝計算並生成grob
- R grid.polygon 繪製多邊形
注:本文由純淨天空篩選整理自R-devel大神的英文原創作品 Draw a Curve Between Locations。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。