通常绘制一个结点,往往效果比较单一,下面所分享的内容,可以用简单代码达到不一样的标识效果,代码非常简洁,对于大家平时绘制类似的节点,会很有帮助,推荐推荐。 效果图: node1   代码如下:

\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz}

\tikzset{every node/.append style={minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,inner sep=0.05cm}}%

\begin{document}
\begin{tikzpicture}
\node[fill=gray!5, thin ] (1a) {$u_{1}$};
\node[fill=gray!10, right of=1a, thick ] (2a) {$u_{2}$};
\node[fill=gray!30, right of=2a, thin ] (3a) {$u_{3}$};
\node[fill=gray!60, right of=3a, thick ] (4a) {$u_{4}$};
\node[fill=gray!30, right of=4a, draw=none] (5a) {$u_{5}$};

\node[fill=black!10, below of=1a, thin ,text=white] (1b) {$v_{1}$};
\node[fill=black!10, right of=1b, thick ,text=white] (2b) {$v_{2}$};
\node[fill=black!30, right of=2b, thin ,text=white] (3b) {$v_{3}$};
\node[fill=black!60, right of=3b, thick ,text=white] (4b) {$v_{4}$};
\node[fill=black!30, right of=4b, draw=none,text=white] (5b) {$v_{5}$};

\node[fill=black!10, below of=1b, thin ,text=gray] (1c) {$x_{1}$};
\node[fill=black!10, right of=1c, thick ,text=gray] (2c) {$x_{2}$};
\node[fill=black!30, right of=2c, thin ,text=gray] (3c) {$x_{3}$};
\node[fill=black!60, right of=3c, thick ,text=gray] (4c) {$x_{4}$};
\node[fill=black!30, right of=4c, draw=none,text=gray] (5c) {$x_{5}$};

\node[fill=black!10, below of=1c, thin ,dashed] (1d) {$y_{1}$};
\node[fill=black!10, right of=1d, thick ,dashed] (2d) {$y_{2}$};
\node[fill=black!30, right of=2d, thin ,dashed] (3d) {$y_{3}$};
\node[fill=black!60, right of=3d, thick ,dashed] (4d) {$y_{4}$};
\node[fill=black!30, right of=4d, draw=none,dashed] (5d) {$y_{5}$};

\node[fill=black!10, below of=1d, thin ,dotted] (1e) {$z_{1}$};
\node[fill=black!10, right of=1e, thick ,dotted] (2e) {$z_{2}$};
\node[fill=black!30, right of=2e, thin ,dotted] (3e) {$z_{3}$};
\node[fill=black!60, right of=3e, thick ,dotted] (4e) {$z_{4}$};
\node[fill=black!30, right of=4e, draw=none,dotted] (5e) {$z_{5}$};
\end{tikzpicture}
\end{document}
效果图: node2   代码如下:
\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{arrows,patterns}

\pgfdeclarepatternformonly{soft horizontal lines}{\pgfpointorigin}{\pgfqpoint{100pt}{1pt}}{\pgfqpoint{100pt}{3pt}}%
{
  \pgfsetstrokeopacity{0.3}
  \pgfsetlinewidth{0.1pt}
  \pgfpathmoveto{\pgfqpoint{0pt}{0.5pt}}
  \pgfpathlineto{\pgfqpoint{100pt}{0.5pt}}
  \pgfusepath{stroke}
}

\pgfdeclarepatternformonly{soft crosshatch}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{4pt}{4pt}}{\pgfqpoint{3pt}{3pt}}%
{
  \pgfsetstrokeopacity{0.3}
  \pgfsetlinewidth{0.4pt}
  \pgfpathmoveto{\pgfqpoint{3.1pt}{0pt}}
  \pgfpathlineto{\pgfqpoint{0pt}{3.1pt}}
  \pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
  \pgfpathlineto{\pgfqpoint{3.1pt}{3.1pt}}
  \pgfusepath{stroke}
}

\begin{document}

\begin{tikzpicture}[
  every node/.style={minimum size=0.5cm, draw,circle,
    font={\sffamily\Large\bfseries},inner sep=0.05cm},
  node distance=1.5cm,>=stealth',bend angle=45,auto]
  \node[pattern=soft horizontal lines] (1) {$v_{1}$};
  \node[fill=gray!10, below of=1, xshift=2cm] (2) {$v_{2}$};
  \node[pattern=dots,right of=2, xshift=1cm] (3) {$v_{3}$};
  \node[below of=2, xshift=-2cm] (4) {$v_{4}$};
  \node[pattern=soft crosshatch,below of=2, xshift=1.5cm] (5) {$v_{5}$};
 \end{tikzpicture}

\end{document}
效果图: node3   代码如下:
\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{arrows,patterns}

\begin{document}
\begin{tikzpicture}[node distance=1.5cm,>=stealth',bend angle=45,auto]
        \node[minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,fill=brown!90,inner sep=0.05cm,draw=none] (1) {\textcolor{white}{$v_{1}$}};
        \node[minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,pattern=fivepointed stars,pattern color=green,inner sep=0.05cm, below of=1, xshift=2cm, thick] (2) {\textcolor{red}{$v_{2}$}};
        \node[minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,pattern=dots,pattern color=blue,inner sep=0.05cm,right of=2, xshift=1cm, thin] (3) {\textcolor{pink}{$v_{3}$}};
        \node[minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,pattern=bricks,pattern color=red,inner sep=0.05cm,below of=2, xshift=1.5cm, thin] (4) {$v_{4}$};
        \node[minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,inner sep=0.05cm,below of=2, xshift=-2cm, very thin,pattern=crosshatch dots,pattern color=red] (5) {$v_{5}$};
         \node[minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,inner sep=0.05cm,right of=2, xshift=1cm, yshift=1.5cm,very thin,pattern=north east lines,pattern color=blue!40] (6) {$v_{6}$};
          \node[minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,inner sep=0.05cm,below of=1, xshift=-1.5cm, very thin,shading=true,inner color=white,outer color=blue!40] (7) {\textcolor{magenta}{$v_{7}$}};
          \node[minimum size=0.5cm, draw,circle,font=\sffamily\Large\bfseries,inner sep=0.05cm,above of=1, xshift=-1.5cm, very thin,shading=true,left color=green,right color=blue!40,text=red] (8) {$v_{8}$};
\end{tikzpicture}
\end{document}
选自:http://tex.stackexchange.com/questions/50934/how-to-mark-a-node-in-a-graph-with-a-pattern

点赞(1)

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部