# How to draw a region of inequality

Could you help me draw a region of this inequality:

\begin{eqnarray}
3x_1 + 3x_2 \geq 27
x_1 + 2x_2 \geq 18
4x_1 + 2x_2 \geq 28
\end{eqnarray}


I need two graphs: one with three inequalities marked with different patters and one with the set of the solution.

Inspired by an answer to a different question I made somethinhg like that: it works, but I can't write anything below and when I tried to change it so it'd show only the solution but that didn't work.

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{patterns}
\makeatletter
\newcommand{\pgfplotsdrawaxis}{\pgfplots@draw@axis}
\makeatother

\pgfplotsset{only axis on top/.style={axis on top=false, after end axis/.code={
\pgfplotsset{axis line style=opaque, ticklabel style=opaque, tick style=opaque,
grid=none}\pgfplotsdrawaxis}}}

\newcommand{\drawge}{-- (rel axis cs:1,0) -- (rel axis cs:1,1) -- (rel axis cs:0,1) \closedcycle}

\begin{document}

\begin{figure}[htpb]
\centering
\label{fig:p3:c1}
\begin{tikzpicture}
\begin{axis}[only axis on top,
axis line style=very thick,
axis x line=bottom,
axis y line=left,
ymin=0,ymax=14,xmin=0,xmax=14,
xlabel=$x_1$, ylabel=$x_2$,grid=major
]

{9-x} \drawge;

\addplot [draw=none, pattern=north west lines, domain=0:14]
{9-0.5*x} \drawge;

{14-2*x} \drawge;
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

• Can you show us what you've tried thus far? It'll provide a foundation from which the community can build to provide you with solutions. – Werner Dec 16 '15 at 20:19
• have you seen tex.stackexchange.com/questions/75933/… – cmhughes Dec 16 '15 at 20:28
• I've seen that, but I know nothing about latex, just found out it exists and I don't understand most parts of codes they used. – U.M. Dec 16 '15 at 20:42

Here is a way with pstricks. I simplified the inequations:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\pagestyle{empty}
\usepackage{array}
\usepackage[svgnames, x11names]{pstricks}%
\usepackage{auto-pst-pdf}

\begin{document}

\everypsbox{\footnotesize}
\psset{labels=none, unit=0.25}
\psset{PointName=none, PointSymbol=none, nodesepA=-20, nodesepB=-20}
\begin{pspicture*}(-10,-10)(26,24)
\psaxes[ticks=none]{->}(0,0)(-10,-10)(26,24)[$x_1$,-120][$x_2$,-140]
\psset{linecolor=IndianRed}
\pnodes{K}(-10,-10)(-10,24)(26,24)(26,-10)
\pnodes{A}(7,0)(9,0)(18,0)
\pnodes{B}(0,0)(0,9)(0,14)
\uput[dl](B0){$O$}
\pstLineAB[linecolor=IndianRed3]{A1}{B1}\uput[d](A1){9}\uput[l](B1){9}
\pstLineAB[linecolor=Coral2]{A2}{B1}\uput[d](A2){18}
\pstLineAB[linecolor=PeachPuff2]{A0}{B2}\uput[d](A0){7}\uput[l](B2){14}
%%Inequalities
\psset{linestyle=none, fillstyle=solid, opacity=0.25, framesize=15pt 5pt }
%%1st inequality
\pstInterLL{K0}{K1}{A1}{B1}{C}
\pstInterLL{K0}{K3}{A1}{B1}{D}
\pspolygon[fillcolor= IndianRed](C)(K1)(K2)(K3)(D)
%%2nd inequality
\pstInterLL{K0}{K1}{A2}{B1}{E}
\pstInterLL{K2}{K3}{A2}{B1}{F}
\pspolygon[fillcolor= Coral2](E)(K1)(K2)(K3)(F)
%%3rd inequality
\pstInterLL{K1}{K2}{A0}{B2}{G}
\pstInterLL{K0}{K3}{A0}{B2}{H}
\pspolygon[fillcolor= PeachPuff3](G)(K2)(K3)(H)
%% Legend
\rput(-5,-5){\setlength\arraycolsep{0.8em}$\begin{array}{@{}l l@{}}% \fnode*[linecolor=IndianRed](0,1.25pt){In1} & x_1 + x_2 \ge 9 \\ \fnode*[linecolor=Coral2](0,1.25pt){In2} & x_1 + 2x_2 \ge 18\\ \fnode*[linecolor=PeachPuff2](0,1.25pt){In2} & 2x_1 + x_2 \ge 14 \end{array}$}
\end{pspicture*}

\end{document}


\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{patterns,intersections}
\makeatletter
\newcommand{\pgfplotsdrawaxis}{\pgfplots@draw@axis}
\makeatother

\pgfplotsset{only axis on top/.style={axis on top=false, after end axis/.code={
\pgfplotsset{axis line style=opaque, ticklabel style=opaque, tick style=opaque,
grid=none}\pgfplotsdrawaxis}}}

\newcommand{\drawge}{-- (rel axis cs:1,0) -- (rel axis cs:1,1) -- (rel axis cs:0,1) \closedcycle}

\pgfplotsset{compat=1.12}
\begin{document}

\begin{figure}[htpb]
\centering
\label{fig:p3:c1}
\begin{tikzpicture}
\begin{axis}[only axis on top,
axis line style=very thick,
axis x line=bottom,
axis y line=left,
ymin=0,ymax=14,xmin=0,xmax=14,
xlabel=$x_1$, ylabel=$x_2$,grid=major
]

{9-x} \drawge;

\addplot [draw=none, pattern=north west lines, domain=0:14]
{9-0.5*x} \drawge;
{14-2*x} \drawge;
\end{axis}
\end{tikzpicture}
\end{figure}

\begin{figure}[htpb]
\centering
\label{fig:p3:c1}
\begin{tikzpicture}
\begin{axis}[only axis on top,
axis line style=very thick,
axis x line=bottom,
axis y line=left,
ymin=0,ymax=14,xmin=0,xmax=14,
xlabel=$x_1$, ylabel=$x_2$,grid=major
]

\addplot[name path global=firstline, very thick, domain=0:14] {9-x};
\addplot[name path global=secondline, very thick, domain=0:14] {9-0.5*x};
\addplot[name path global=thirdline, very thick, domain=0:14] {14-2*x};
%Repeat next line with a different pattern to show a pattern mixture
%over this region.
\fill[name intersections={of=secondline and thirdline, by=pointtwo}][pattern=vertical lines] (rel axis cs:0,1) -- (pointtwo)--(14,2)|-cycle;
\end{axis}
\end{tikzpicture}
\end{figure}\end{document}