6

Any idea how to draw this using Latex. Having difficulties with the shaded region.

enter image description here

\begin{figure}[h]
\begin{tikzpicture}
   \tkzInit[xmax=6,ymax=6,xmin=-6,ymin=-6]
   \tkzAxeXY
   \draw[ thick,latex-latex] (0,5) -- (5,-5) ; 
 \draw[ thick,latex-latex] (-5,0) -- (5,-5) ;
 \draw[ thick,latex-latex] (0,5) -- (-5,0) ;
  \end{tikzpicture}
\end{figure}
4
  • 2
    You say you have difficulties with the shaded parts, can you show us what you got so far? This is also important to know what package you are using.
    – Johannes_B
    Commented Oct 6, 2015 at 9:45
  • @Johannes_B. See edited. It is so different from the image. I don't know how to get rid of the numbers on the axis. And somehow the line I draw seems to have arrows at the end which I don't need. Commented Oct 6, 2015 at 10:06
  • You are asking for arrows with the option latex-latex. Remove it if you don't want arrows. Use -latex (or latex-) if you want arrow only at the end (or beginning).
    – JLDiaz
    Commented Oct 6, 2015 at 10:08
  • thx @JLDiaz for explaining about the arrows. Commented Oct 6, 2015 at 11:13

4 Answers 4

9
\documentclass{article}
\usepackage{tikz}
\tikzset{mynode/.style={fill=white,text=black,font=\tiny,inner sep=1pt}
}
\begin{document}
  \begin{tikzpicture}[x=2cm,y=2cm]    
    \filldraw[gray!60] (0,1) |- (1,2) -- (0,1)node[pos=0.5,mynode] {$\phi = \theta + 1$};
    \filldraw[gray!60] (1,1) -- (1,2) -- (2,0)node[pos=0.25,mynode,xshift=2ex] {$\phi = 1-2\theta$}
                       |- (1,1);
    \filldraw[gray!60] (0,1) -| (1,0.5) |- (2,0)
                       -- (0,1)node[pos=0.75,mynode] {$2\phi = -\theta - 1$};
    \draw[very thick] (0,0) rectangle (2,2);
    \draw (-0.5,1) -- (2.5,1)node[below,pos=0.95,mynode]{$\theta$}
          (1,-0.5) -- (1,2.5)node[right,pos=0.95,mynode]{$\phi$};
  \end{tikzpicture}
\end{document}

enter image description here

2
  • great @Harish.. this is perfect! Thank you so much. Commented Oct 6, 2015 at 11:12
  • For the filling, you can also make use of the even odd rule and just specify the squares and triangle: \fill[gray!50,draw=gray,even odd rule] (0,4) rectangle ++ (4,4) (4,0) rectangle ++ (4,4) (8,0) -- (0,4) -- (4,8) -- (8,0); Commented Nov 16, 2015 at 21:53
6

I propose this layout, with pstricks:

\documentclass[ a4paper, x11names, border=3pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{eulervm}
\usepackage{pst-plot, pst-node}
\usepackage{auto-pst-pdf}

\begin{document}

\small\sffamily

\begin{pspicture}(-5,-5)(5,5)
    \psset{unit=4, arrowinset=0.15, linecolor=LightSteelBlue4, linejoin=1, dimen=middle, shortput=nab}
    \psaxes[ticks=none, labels=none](0,0)(-1.25,-1.25)(1.25,1.25)[$\theta$,0][$\phi$,90]
    \psframe[linewidth=1.2pt](-1,-1)(1,1)
    \pnodes{A}(-1,1)(0,1)(1,1) \pnodes{B}(-1,0)(0,0)(1,0) \pnodes{C}(-1,-1)(0,-1)(1,-1)
    \psset{fillstyle=solid, fillcolor=Azure3!50!}
    \pspolygon(B0)(A0)(A1)
    \pspolygon(B1)(A1)(C2)(B2)
    \pspolygon(B0)(B1)(C1)(C2)
    \psset{linewidth=0pt, nrot=:U}
    \ncline{B0}{A1}_{$\phi =\theta+1$}
    \ncline{A1}{C2}^[npos=0.35]{$\phi =1-2\theta$}
    \ncline{B0}{C2}_[npos=0.35]{$2\phi =-\theta-1$}
\end{pspicture}

\end{document} 

enter image description here

0
2

My solution, very easy:

\documentclass[tikz,border=2mm]{standalone}

\begin{document}
\begin{tikzpicture}%[scale=1]
\fill [purple!10] (-4,4) -- (0,4) -- (-4,0);
\fill [purple!10] (0,0) -- (0,4) -- (2,0);
\fill [purple!10] (0,0) -- (-4,0) -- (0,-2);
\fill [purple!10] (0,-2) -- (0,-4) -- (4,-4);
\fill [purple!10] (2,0) -- (4,0) -- (4,-4);
\draw [->] (-5,0) -- (5,0) node [below] {\large $\theta$};
\draw [->] (0,-5) -- (0,5) node [right] {\large $\phi$};
\draw (-4,-4) rectangle (4,4);
\draw (4,-4) -- (0,4) -- (-4,0) -- cycle;
\node at (-1.5,1.5) {\large $\phi=\theta+1$};
\node at (2.1,2.1) {\large $\phi=1-2\theta$};
\node at (-1.9,-1.9) {\large $2\phi=-\theta-1$};
\end{tikzpicture}
\end{document}

screenshot of output

1

Making use of the even odd rule for the shaded part, and defining a \cellsize to make the size easily modifiable. Also, here you can play around with it.

Code

\documentclass[tikz, border=2mm]{standalone}

\begin{document}

\pgfmathsetmacro{\cellsize}{4}

\begin{tikzpicture}
    \draw[-latex] (-0.25*\cellsize,\cellsize) -- ++ (2.5*\cellsize,0) node[below] {$\epsilon$};
    \draw[-latex] (\cellsize,-0.25*\cellsize) -- ++ (0,2.5*\cellsize) node[right] {$\tau$};
    \draw (0,0) rectangle ++ (2*\cellsize,2*\cellsize);
    \fill[gray!50,draw=black,even odd rule] (0,\cellsize) rectangle ++ (\cellsize,\cellsize)
        (\cellsize,0) rectangle ++ (\cellsize,\cellsize)
        (2*\cellsize,0) -- node[sloped, below, pos=0.75, black] {$\alpha+\beta$}
        (0,\cellsize) -- node[sloped, below, pos=0.5, black] {$\delta+\kappa$}
        (\cellsize,2*\cellsize) -- node[sloped, above, pos=0.25, black] {$\omega-\pi$} (2*\cellsize,0);
\end{tikzpicture}

\end{document}

Output

enter image description here

You must log in to answer this question.

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