前文有提到座標或是節點的label指令的用法,其實還有一個用來標示的功能是pin。
在TiKz的文件中,有一節是專門討論這二者的用法。
label=[options] angle:text,如
\coodinate[label=A] (a) at (1,2) ;
label 的 options 通常用在node上面。而 angle 則是要標示的位置是在點的那個方位。如上方:
label=above:A或 label=90:A
absolute 則用以node的平均座標位置來標示:
\draw[help lines] (0,0) grid (5,5);
\node at (1,3) [rotate=-80, draw][label={[red,draw]right:label}]{main node};
\node at (3,3) [rotate=-80, draw][label={[red,draw, absolute]right:label}]{main node};
label distance=長度,則是設定label 的距離:
\node at (1,1) [fill=blue!50,circle,inner sep=0.5 cm][label={[text=red]above:A}] [label={[text=brown,label distance=1cm]right:B}][pin={[pin distance=1.5cm, pin edge={thick}, inner sep=1pt]40:C}]{};
如下圖的A和設定距1cm的B。
pin的用法和label幾乎一樣:
pin=[options] angle: text
差別是多出一條直線連向node。參數一樣有 pin distance,不過它多出一條線的關係,所以多了一個pin edge,可以對這條連線做各種的設定。如上例C。
其實二者都是node的一種,所以node的相關參數都能使用。
下面一例是畫出一個恒星,行星,衛星的示意圖,因用到坐標的運算,所以需要使用calc library,使用pin指令來說明:
\usetikzlibrary{calc}
\node[inner color=white, outer color=orange, inner sep=0.5cm,circle, pin={[pin distance=4cm, pin edge=red, text=blue]130: Star}] at (2.5,2.5) {};
\draw[line width=2pt, draw=gray!80] (5,2.5) arc [start angle=0, end angle=360, x radius=2.5cm, y radius=2cm]node [name=earth, pos=0.6,ball color=blue!70,shading angle=-100, circle, pin={[pin distance=2cm,text=blue,pin edge=red, name=pinearth]left: Planet}]{};
限會員,要發表迴響,請先登入