4

Suppose I have simple graph drawing like the following.

\documentclass[12pt,a4paper]{article}
\usepackage{tkz-graph}

\begin{document}

\begin{figure}
\begin{tikzpicture}

\SetUpEdge[lw = 1.5pt, color = black, labelcolor = white]
\GraphInit[vstyle=Classic]

\tikzset{VertexStyle/.append style = {minimum size = 8pt, inner sep = 0pt}}     

\Vertices[unit=2]{circle}{a,b,c,d,e,f}

% It's easy to change the color of a vertex!
\AddVertexColor{white}{a,d} 
\Edges(a,b,c,d,e,f,a)

\end{tikzpicture}
\end{figure}

\end{document}

From the documentation, I could figure out how to change the color of a vertex, as is done in the code. However, I'd like to use only black and white to represent several colors. For example, could I have a vertex that is filled with black bars? If so, how? This could represent "blue", while vertex filled with black is "green", and a vertex filled with white is "red".

mrm
  • 189

1 Answers1

4

Load the patterns library, and add pattern=<style> to the definition of VertexStyle, where <style> include, for example, horizontal lines, vertical lines, north east lines, north west lines, etc.

Code

\documentclass[12pt,a4paper]{article}
\usepackage{tkz-graph}
\usetikzlibrary{patterns}

\begin{document}

\begin{figure}
\begin{tikzpicture}

\SetUpEdge[lw = 1.5pt, color = black, labelcolor = white]
\GraphInit[vstyle=Classic]

\tikzset{VertexStyle/.append style = {minimum size = 8pt, inner sep = 0pt, pattern=north east lines}}     

\Vertices[unit=2]{circle}{a,b,c,d,e,f}

% It's easy to change the color of a vertex!
\AddVertexColor{white}{a,d} 
\Edges(a,b,c,d,e,f,a)

\end{tikzpicture}
\end{figure}

\end{document}

Output

enter image description here

Herr K.
  • 17,946
  • 4
  • 61
  • 118