I want to show a hexahedron and fill the top face with grey colour. But I am not sure how to do this. My present code does everything, but to have a coloured face:
Code: Select all
\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
\def\width{7}
% vertices
\coordinate (l1) at (0,0);
\coordinate (l2) at (\width,0.1*\width);
\coordinate (l3) at (0.4*\width,0.6*\width);
\coordinate (l4) at (-0.33*\width,0.5*\width);
\coordinate (u1) at (0.2*\width,0.7*\width);
\coordinate (u2) at (\width,\width);
\coordinate (u3) at (0.4*\width,1.1*\width);
\coordinate (u4) at (-0.4*\width,\width);
%%\draw[step=.5cm,gray,very thin] (-0.5*\width,-0.1*\width) grid (1.2*\width,1.2*\width);
% hexahedral
\begin{scope}[thick]
\draw (l1) -- (l2);
\draw (l1) -- (l4);
\draw (l1) -- (u1);
\draw (l4) -- (u4);
\draw (l2) -- (u2);
\draw (u1) -- (u2);
\draw (u1) -- (u4);
\draw (u3) -- (u4);
\draw (u3) -- (u2);
\end{scope}
% hidden lines
\begin{scope}[dashed,thick]
\draw (l4) -- (l3);
\draw (l2) -- (l3);
\draw (l3) -- (u3);
\end{scope}
% arrows
\begin{scope}[->,>=latex]
\draw (2.5,3.5) circle (0.4ex) [fill];
\draw (2.5,3) [fill=white] node {cell (i, j, k)};
\draw (2.5,6.5) -- ++(0,1.5) node [at end, right]{$n_m$};
\draw (1.5,6.3) [fill=white] node {$A_m$};
\draw (6,3.5) -- ++(1.75,-0.5);
\draw (-1.5,4.5) -- ++(-1.5,-0.25);
%% \draw [dashed] (2,2.5) -- ++(0,-1);
%% \draw [dashed] (5,4.5) -- ++(0.7,0.7);
%% \draw [dashed] (0.5,5.5) -- ++(-0.9,0.9);
\end{scope}
\end{tikzpicture}
\end{document}