Tikz如何标注一个节点或图案

通常绘制一个结点,往往效果比较单一,下面所分享的内容,可以用简单代码达到不一样的标识效果,代码非常简洁,对于大家平时绘制类似的节点,会很有帮助,推荐推荐。 效果图: 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
分享到:
未经允许不得转载:Tikz如何标注一个节点或图案
已有 条意见

    最新文章

    加载中...
      本站提供专业LaTeX排版、咨询、定制服务,请点击下图咨询详情


      全国首个精品的LaTeX视频教程,大牛带着你入门,让LaTeX学习不再纠结,请点击下图咨询详情

      热门评论

        联系我们

        交流QQ群:91940767
        本站QQ号:343083553
        邮箱联系latexstudio@qq.com
        淘宝店铺latexstudio.taobao.com 提供排版,模板定制,培训,图片处理,视频教程等LaTeX服务。

        关注微信公众号: latex2015

        如果您投稿或者希望加入我们团队,请发送您的简历到latexstudio@qq.com。

        科技艺术的完美融合,专业精致的排版体验

        联系我们联系我们