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".

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Speravir Jan 22 '14 at 17:51
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.