1

I have the following MWE with some help from the community:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz} 
\usetikzlibrary{positioning}
\usepackage{commath}
\usepackage{float}
\usepackage{mathtools} 
\usetikzlibrary{3d,perspective}

%Color Define
% colors
\definecolor{side}    {HTML}{879EA4}
\definecolor{top}     {HTML}{AAC7CF}
\definecolor{myorange}{HTML}{EA8032}
\definecolor{foo}{HTML}{EFF5F9}
\definecolor{magenta}{HTML}{FF00FF}
\definecolor{mygray}{gray}{0.6}
\definecolor{apricot}{HTML}{fbceb1}

\begin{document}

\begin{figure}[!htbp]
\centering
\begin{tikzpicture}[scale=1.25,
auto,isometric view,rotate around z=-65,
                    line join=round,line cap=round]
  \foreach\i in {0,-15}
    \draw[rotate around z=\i,canvas is xz plane at y=0]
      (0,0) -| (10,8) -- (2.5,8) -- (2.3,6) -| (1.3,7) -| cycle;
  \foreach\i/\j in {10/0,10/8,2.5/8,2.3/6,1.3/6,1.3/7}
    \draw[canvas is xy plane at z=\j, fill=none] (0:\i) arc (0:-15:\i);
  
  \useasboundingbox (current bounding box.north west) -- (current bounding box.south east);
  
  \begin{scope}[canvas is xy plane at z=7]
    \clip (0,0) circle [radius=1.3];
    \draw[shift={(-15:0.6)},rounded corners,fill=myorange] (0,0) -- (-15:1) arc (-15:0:1) -- cycle;
  \end{scope}
\end{tikzpicture}
\caption{3D Model.}
\label{3DModel}
\end{figure}

\end{document}

This Gives: enter image description here

However, I now want to label the faces with different colors and then show the labeling as shown in the following figure. I edited the figure using Paint. enter image description here

2
  • As for the colored surfaces, you can do this the same way you aready did for the orange surface: redraw it and fill it with the appropriate color. You can simply add a legend by drawing squares and add some text. What exactly do you have problems with? Jul 25, 2022 at 7:11
  • Hi @JasperHabicht, I was unable to color the faces for some reason. The colors were taking place in the adjacent lines only! I see you comment below, thanks.
    – Rahman
    Jul 25, 2022 at 8:22

1 Answer 1

1

You essentially need to redraw the surfaces and fill them with the appropriate color. You can use scopes with option canvas is xy plane at z to shift your drawing plane to another level to draw the surfaces or define coordinates.

As for the legend, I would suggest that you place the main drawing in a scope that defines the isometric view to be able to add a legend where this option is not applied.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz} 
\usetikzlibrary{positioning}
\usetikzlibrary{3d,perspective}
\usepackage{commath}
\usepackage{float}
\usepackage{mathtools} 

%Color Define
% colors
\definecolor{side}    {HTML}{879EA4}
\definecolor{top}     {HTML}{AAC7CF}
\definecolor{myorange}{HTML}{EA8032}
\definecolor{foo}     {HTML}{EFF5F9}
\definecolor{magenta} {HTML}{FF00FF}
\definecolor{mygray}  {gray}{0.6}
\definecolor{apricot} {HTML}{fbceb1}

\begin{document}

\begin{figure}[!htbp]
\centering
\begin{tikzpicture}

  \begin{scope}[scale=1.25,
    auto,isometric view,rotate around z=-65,
    line join=round,line cap=round]
                    
  \begin{scope}[canvas is xy plane at z=7]
    \fill[apricot] (0:0) -- (-15:1.3) arc (-15:0:1.3) -- cycle;
    \coordinate (a2) at (0:1.3);
  \end{scope}
  
  \begin{scope}[canvas is xy plane at z=7]
    \coordinate (a2) at (0:1.3);
  \end{scope}
  \fill[magenta] (a2) arc (0:-15:1.3) -- +(0,0,-1) arc (-15:0:1.3)  -- cycle;

  \begin{scope}[canvas is xy plane at z=8]
    \coordinate (a1) at (0:2.5);
  \end{scope}
  \begin{scope}[canvas is xy plane at z=6]
    \fill[magenta] (0:1.3) arc (0:-15:1.3) -- (-15:2.3) arc (-15:0:2.3) -- cycle;
    \fill[magenta] (-15:2.3) arc (-15:0:2.3) -- (a1) arc (0:-15:2.5) -- cycle;
  \end{scope}
  
  \fill[mygray] (0:0) -- (0:10) arc (0:-15:10);
  
  \fill[top] (0:10) arc (0:-15:10) -- +(0,0,8) arc (-15:0:10) -- cycle;
  \begin{scope}[canvas is xy plane at z=8]
    \fill[top] (0:2.5) +(0,0,8) arc (0:-15:2.5) -- (-15:10) arc (-15:0:10) -- cycle;
  \end{scope}
                    
  \foreach\i in {0,-15}
    \draw[rotate around z=\i,canvas is xz plane at y=0]
      (0,0) -| (10,8) -- (2.5,8) -- (2.3,6) -| (1.3,7) -| cycle;
  \foreach\i/\j in {10/0,10/8,2.5/8,2.3/6,1.3/6,1.3/7}
    \draw[canvas is xy plane at z=\j, fill=none] (0:\i) arc (0:-15:\i);

  \begin{scope}[canvas is xy plane at z=7]
    \clip (0,0) circle [radius=1.3];
    \draw[shift={(-15:0.6)},fill=myorange] (0,0) -- (-15:1) arc (-15:0:1) -- cycle;
  \end{scope}
  
  \end{scope}
  
  \begin{scope}[y=.5cm, xshift=-2cm, yshift=-1cm]
  \node[rectangle, draw, fill=myorange, label={0:{Label 1}}] at (0,0) {};   
  \node[rectangle, draw, fill=magenta, label={0:{Label 2}}] at (0,-1) {};    
  \node[rectangle, draw, fill=top, label={0:{Label 3}}] at (0,-2) {};    
  \node[rectangle, draw, fill=apricot, label={0:{Label 4}}] at (0,-3) {};    
  \node[rectangle, draw, fill=mygray, label={0:{Label 5}}] at (0,-4) {};    
  \node[rectangle, draw, fill=white, label={0:{Label 6}}] at (0,-5) {};    
  \end{scope}
 
  \useasboundingbox (current bounding box.north west) -- (current bounding box.south east);
  
\end{tikzpicture}
\caption{3D Model.}
\label{3DModel}
\end{figure}

\end{document}

enter image description here

1
  • Thanks for the perfect answer, Jasper! I appreciate your help & time.
    – Rahman
    Jul 25, 2022 at 8:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .