0

I try to draw the following picture using LaTeX:

wanted

I try the follwoing code but it does not look similar to what I want:

\documentclass{article}
\usepackage{tikz}

\definecolor{cof}{RGB}{219,144,71}
\definecolor{pur}{RGB}{186,146,162}
\definecolor{greeo}{RGB}{91,173,69}
\definecolor{greet}{RGB}{52,111,72}

\begin{document}

\begin{tikzpicture}[thick,scale=5]
\coordinate (A1) at (0, 0);
\coordinate (A2) at (0, 1);
\coordinate (A3) at (1, 1);
\coordinate (A4) at (1, 0);
\coordinate (B1) at (0.5, 0.5);
\coordinate (B2) at (0.3, 1.3);
\coordinate (B3) at (1.3, 1.3);
\coordinate (B4) at (1.3, 0.3);

\draw[very thick] (A1) -- (A2);
\draw[very thick] (A2) -- (A3);
\draw[very thick] (A3) -- (A4);
\draw[very thick] (A4) -- (A1);

\draw[dashed] (A1) -- (B1);
\draw[dashed] (B1) -- (B2);
\draw[very thick] (A2) -- (B2);
\draw[very thick] (B2) -- (B3);
\draw[very thick] (A3) -- (B3);
\draw[very thick] (A4) -- (B4);
\draw[very thick] (B4) -- (B3);
\draw[dashed] (B1) -- (B4);

\draw[fill=yellow,opacity=0.6] (A1) -- (B1) -- (B4) -- (A4);
\draw[fill=black!20,opacity=0.5] (A1) -- (A2) -- (A3) -- (A4);
\draw[opacity=0.6] (A1) -- (A2) -- (B2) -- (B1);
\draw[opacity=0.6] (B1) -- (B2) -- (B3) -- (B4);
\draw[opacity=0.6] (A3) -- (B3) -- (B4) -- (A4);
\draw[opacity=0.6] (A2) -- (B2) -- (B3) -- (A3);

\end{tikzpicture}

\end{document}
2
  • Why do you have the plot tag but there is no plot in your code? Also, do you want the figure to be actual 3D?
    – Alenanno
    Jan 7, 2016 at 15:00
  • the phrase you're looking for is 'rectangular prism' Jan 7, 2016 at 15:13

1 Answer 1

1

I have redone your graph, now you have less commands. I suppose that the dots were random to begin with so I did them randomly. I'm not sure how you wanted to color the picture, so I left it black and white for now. If you have trouble coloring a section, let me know.

Updates:

  • added custom style for background square with different border colors.

Output

enter image description here

Code

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}

\usetikzlibrary{calc}

\definecolor{cof}{RGB}{219,144,71}
\definecolor{pur}{RGB}{186,146,162}
\definecolor{greeo}{RGB}{91,173,69}
\definecolor{greet}{RGB}{52,111,72}

\tikzset{%
    nod/.style={draw,minimum height=3cm, minimum width=2cm, anchor=south west, outer sep=0, text height=3ex},
    nodc/.style={nod,draw=none,append after command={%
        (\tikzlastnode.south east) edge[gray] (\tikzlastnode.south west) 
        (\tikzlastnode.south west) edge[gray] (\tikzlastnode.north west)
        (\tikzlastnode.north west) edge (\tikzlastnode.north east) 
        (\tikzlastnode.north east) edge (\tikzlastnode.south east)
        }
    },
}

\begin{document}
\begin{tikzpicture}[thick]
\node[nod, label=90:A] (a) at (0,0) {$cosx$};
\node[nod, label=90:B] (b) at (2,0) {$sinx$};
\node[nodc, minimum height=2cm, minimum width=2.8cm] (c) at (5,4.5) {};
\draw (a.north west) -- (c.north west);
\draw (b.north east) -- (c.north east);
\draw (b.south east) -- (c.south east);
\draw[dashed, gray] (a.south west) -- (c.south west);

\node[fill=black, circle, inner sep=3pt] (dot) at ($(b.north west-|c.south west)+(.5,0)$) {};
\draw[->] (dot) --++ (2,0) coordinate (ar);
\draw (ar)++(.1,0) to[out=0,in=0, looseness=2] ($(dot)+(1,5)$)
    edge[out=180,in=180,looseness=2,->] ($(a.north east)+(0,1.5)$);
\begin{scope}[shift={(2.5,-.2)}]
\draw plot [only marks, mark=*, mark size=1pt, domain=2:4, samples=20] (\x,{rnd*1.25+3.5/5*\x+0.5});
\end{scope}
\end{tikzpicture}
\end{document}

You must log in to answer this question.

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