Skip to content

TikZPicture

一个 TikZ 的基础图元素

介绍

PGFplots 的所有的绘图工作都应该包含在 TikZPicture 块中:

latex
\begin{tikzpicture}[<options>]
  \begin{axis}[<options>]
  \end{axis}
\end{tikzpicture}

TikZPictureoptions 对块内的所有元素生效:

latex
\begin{tikzpicture}[outline/.style={draw=#1,thick,fill=#1!50}]
  \node [outline=red]  at (0,1) {red};
  \node [outline=blue] at (0,0) {blue};
\end{tikzpicture}

其中 outline/.style={draw=#1,thick,fill=#1!50} 配置包含在该 TikZPicture 中所有 outline 的样式。

当有元素启用 outline 特性时生效,但当参数重复时,优先使用子节点配置的样式。

除了配置样式 style 之外,还可以配置其他的 key 如 default:

latex
\begin{tikzpicture}[outline/.style={draw=#1,thick,fill=#1!50},
                    outline/.default=black]
  \node [outline]      at (0,1) {default};
  \node [outline=blue] at (0,0) {blue};
\end{tikzpicture}

更多有关key的介绍可以查看:PGFKeys