0

I used examples from here and here to draw my pyramid. I only need 3 sections and I am in wired position where I know how to have a pyramid with equal spacing and another with color, but not both. I would like to have the top pyramid (shape) with colors. Also I would like to know how to change the shape in the bottom pyramid, because just changing the coordinates results in 3 overlapping triangles.

enter image description here

\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{intersections,backgrounds}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}

\begin{document}

\begin{figure}[htp] \centering \begin{tikzpicture} \coordinate (A) at (-5,0) {}; \coordinate (B) at ( 5,0) {}; \coordinate (C) at (0,7) {}; \draw[name path=AC] (A) -- (C); \draw[name path=BC] (B) -- (C); \foreach \y/\A in { 0/bottom, 2/middle , 4/hoch} { \path[name path=horiz] (A|-0,\y) -- (B|-0,\y); \draw[name intersections={of=AC and horiz,by=P}, name intersections={of=BC and horiz,by=Q}] (P) -- (Q) node[midway,above,align=center,text width= \dimexpr(6em-\y em)*5\relax] {\A}; } \end{tikzpicture}

\begin{tikzpicture}[x=2.5cm,y=2cm] \coordinate (A) at (-3,-1) {}; \coordinate (B) at (3,-1) {}; \coordinate (C) at (0,5) {}; \foreach \A/\col [count=\i] in {bottom/yellow,middle/blue,top/orange} \draw[fill=\col] (C)--([shift={(-.5\i,1\i)}]B)--node[above,align=center] {\A}([shift={(.5\i,1\i)}]A)--cycle; \end{tikzpicture} \end{figure} \end{document}

Namal
  • 301

1 Answers1

1

pyramid equally divided

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
    \begin{tikzpicture}
        \def\r{5} % Radius of your triangle
    \foreach \i in {1,2,3} \coordinate (\i) at (90+120*\i:\r);
    \draw[fill=orange] (1) -- (2) node[above,midway] {bottom} -- (3) -- cycle;
    \path (1) -- (3) coordinate[pos=0.33] (a1) coordinate[pos=0.66] (a2);
    \path (2) -- (3) coordinate[pos=0.33] (b1) coordinate[pos=0.66] (b2);
    \foreach \i/\clr/\txt in {1/blue/middle,2/yellow/top} \draw[fill=\clr] (3) -- (b\i) -- (a\i) node[above,midway] {\txt} -- cycle;
\end{tikzpicture}

\end{document}

SebGlav
  • 19,186