4

I would like some help to get this figure in LaTex:

enter image description here

with the shapes shaded. This is what I have so far.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{intersections,calc}
\usepackage{tikz-3dplot}

\begin{document}


\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[scale=3,tdplot_main_coords,>=latex]
    \filldraw[
        draw=blue,%
        fill=blue!20,%
    ]          (0,0,1)
            -- (0,1,0)
            -- (1,0,0)
            -- cycle;
    \filldraw[
        draw=blue,%
        fill=blue!20,%
    ]          (0,1,0)
            -- (-1,0,0)
            -- (0,0,1)
            -- cycle;
    \filldraw[
        draw=blue,%
        fill=blue!20,%
    ]          (1,0,0)
            -- (0,-1,0)
            -- (0,0,1)
            -- cycle;
    \filldraw[
        draw=blue,%
        fill=blue!20,%
    ]          (0,-1,0)
            -- (-1,0,0)
            -- (0,0,1)
            -- cycle;
\filldraw[
draw=blue,%
fill=blue!20,%
    ]          (1,0,0)
            -- (0,1,0)
            -- (0,0,-1)
            -- cycle;
\filldraw[
draw=blue,%
fill=blue!20,%
    ]          (1,0,0)
            -- (0,-1,0)
            -- (0,0,-1)
            -- cycle;

    \filldraw[
        draw=red,%
        fill=red!20,%
    ]          (1,1,1)
            -- (1,-1,1)
            -- (-1,-1,1)
            -- (-1,1,1)
            -- cycle;             
    \draw[thick,->] (-2,0,0) -- (2,0,0) node[anchor=north east]{$x$};
    \draw[thick,->] (0,-2,0) -- (0,2,0) node[anchor=north west]{$y$};
    \draw[thick,->] (0,0,-2) -- (0,0,2) node[anchor=south]{$z$};
\end{tikzpicture}

\end{document} 

enter image description here

  • Can you say something about the lines in the second figure? Are they intersecting, and is anything known about these lines, i.e. starting points or direction / vectors? – JMP Mar 24 '16 at 23:32
  • I think you are almost there, you need to rearrange some elements so they have the correct "z" ordering. (TikZ doesn't hide elements, you have to do it manually). So elements need to be "broken" in parts to simulate the hiding. TikZ transparency will also help. – alfC Mar 25 '16 at 0:26
  • I've tweaked the code given yesterday a little more. Does this now result in what you've wanted? – JMP Mar 25 '16 at 10:52
6

I made life a little easier by drawing the diamond with the help of \foreach statements and \ifthenelse from the ifthen package. What was basically missing in your work so far was some opacity (see pgf manual section 23)

EDIT

I've tweaked the code given before a little more. I couldn't make the y-axis horizontal, while keeping the z-axis vertical and the x-axis visible by rotating the figures. So I decided to use a non orthogonal coordinate system, by changing the x vector (see annotation of the code). When drawing the second figure, I assumed the lines intersect at (0,-0.5,1).

Edit

Defined the x-vector causing the non-orthogonality of the coordinate system in the tikzpicture options to simplify code.

Note that the code results in a two-sided document

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{intersections,calc}
\usepackage{tikz-3dplot}
\usepackage{ifthen}

\begin{document}

\tdplotsetmaincoords{70}{90}
\begin{tikzpicture}[scale=3,tdplot_main_coords,>=latex, x={(1,-0.5,0)}]
        %
    % plotting the coordinate system before the diamond to make it appear covered
    % setting the x-vector to x={(1,-0.5,0)} enables to plot a non orthogonal coordinate system
        %
    \draw[thick] (-2,0,0)--(-1,0,0);
    \draw[thick,dashed](-1,0,0)--(1,0,0);
    \draw[thick] (0,-2,0)--(0,-1,0);
    \draw[thick,dashed](0,-1,0)--(0,1,0);
    \draw[thick,->] (0,1,0)--(0,2,0) node[anchor=north east]{$y$};
    \draw[thick] (0,0,-2)--(0,0,-1);
    \draw[thick,dashed](0,0,-1)--(0,0,1);

    % plotting the diamond by repeated commands
    \foreach \x in {-1,1}{
        \foreach \y in {-1,1} {
            \foreach \z in {-1,1} {
                \ifthenelse{\x=-1}{
                \filldraw[fill opacity=0.3, draw=blue, fill=blue!20, loosely dashed]
                (0,0,\z)--(0,\y,0)--(\x,0,0)--cycle;
                }{
                \filldraw[fill opacity=0.3, draw=blue, fill=blue!20]
                (0,0,\z)--(0,\y,0)--(\x,0,0)--cycle;
                }
            }
        }
    }

    % plotting the plane and the annotation $\Theta$ at the correct point
    \filldraw[fill opacity=0.75, draw=red, fill=red!20]
    (0.75,1,1)--(0.75,-1,1)--(-0.75,-1,1) node[above] {$\Theta$}--(-0.75,1,1)--cycle;

    % plotting the part of the axes which is not covered by the diamond
    \draw[thick,->] (0,0,1)--(0,0,2) node[anchor=north east]{$z$}; 
    \draw[thick,->] (1,0,0)--(2,0,0) node[anchor=north east]{$x$}; 

    % plotting point at upper tip of diamond and annotation     
    \filldraw[ultra thick] (0,0,1) circle (0.5pt) ++ (0,-0.14,0.1) node{(0,0,1) \ $\hat{\theta}$};
%   
\end{tikzpicture}
%
%
\tdplotsetmaincoords{70}{90}
\begin{tikzpicture}[scale=3,tdplot_main_coords,>=latex, x={(1,-0.5,0)}]

    % plotting the coordinate system before the diamond to make it appear covered
    % setting the x-vector to x={(1,-0.5,0)} enables to plot a non orthogonal coordinate system
    \draw[thick] (-2,0,0)--(-1,0,0);
    \draw[thick,dashed](-1,0,0)--(1,0,0);
    \draw[thick] (0,-2,0)--(0,-1,0);
    \draw[thick,dashed](0,-1,0)--(0,1,0);
    \draw[thick,->] (0,1,0)--(0,2,0) node[anchor=north east]{$y$};
    \draw[thick] (0,0,-2)--(0,0,-1);
    \draw[thick,dashed](0,0,-1)--(0,0,1);

    % plotting the diamond by repeated commands
    \foreach \x in {-1,1}{
        \foreach \y in {-1,1} {
            \foreach \z in {-1,1} {
                \ifthenelse{\x=-1}{
                \filldraw[fill opacity=0.3, draw=blue, fill=blue!20, loosely dashed]
                (0,0,\z)--(0,\y,0)--(\x,0,0)--cycle;
                }{
                \filldraw[fill opacity=0.3, draw=blue, fill=blue!20]
                (0,0,\z)--(0,\y,0)--(\x,0,0)--cycle;
                }
            }
        }
    }

    % plotting the part of the axes which is not covered by the diamond
    \draw[thick,->] (0,0,1)--(0,0,2) node[anchor=north east]{$z$}; 
    \draw[thick,->] (1,0,0)--(2,0,0) node[anchor=north east]{$x$};  

    % plotting points at upper tip and left line of diamond and annotation   
    \filldraw[ultra thick] (0,0,1) circle (0.5pt) ++ (0,0.1,0.1) node{$\hat{\theta}_1$};
    \filldraw[ultra thick] (0.5,-0.5,0) circle (0.5pt) ++ (0,-0.1,-0.1)node{$\hat{\theta}_2$};

    % plotting upper line and annotation   
    \draw (0,1.5,1) node[above left]{$\Theta_1$} --(0,-1.5,1);

    % plotting vertical line and annotation, I assumed the lines to intersect at (0,-0.5,1)
    \draw (1,-0.5,-1) node[right]{$\Theta_2$}--(-0.25,-0.5,1.5);
\end{tikzpicture}

\end{document}

enter image description here enter image description here

  • 1
    Nice. I would draw a secondary "z" arrow at the end to be "in front" of the pink plane: \draw[thick,->] (0,0,1) -- (0,0,2) node[anchor=south]{$z$}; (And the "x" arrow, before drawing the last face, but that can be complicated.) – alfC Mar 24 '16 at 23:13
  • 2
    Changed the code to draw the axes before the diamond and added dashed parts, where the axes are behind the diamond – JMP Mar 24 '16 at 23:20
  • 1
    Sincerest Thanks for all your time and help. – Joe Mar 25 '16 at 13:44

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.