Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

It looks very beautiful! I'd love it! See http://www.science4all.org/le-nguyen-hoang/integer-programming/

Do someone know what software can draw this kind of figure? I'm interested in learning it.

Thanks! enter image description here

share|improve this question
1  
It might be created by PSTricks. –  Oh my ghost Dec 1 '13 at 9:13
3  
–1: Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. Notify me with the @ syntax, when you added a MWE and I'd be happy to redeem my down vote ;-) –  Tobi Dec 1 '13 at 9:36
    
Start with this: texample.net/tikz/examples/j-curve –  alfC Dec 1 '13 at 9:38
2  
@Tobi Thanks for your kindly reminder. Actually I just want to know which software can do that. I don't mean to draw this figure. :) –  Hinn Dec 1 '13 at 15:53
    
I'm the one who did the figure. I used Inkscape. I'm glad you like it! Cheers, Lê. –  Lê Nguyên Hoang Dec 1 '13 at 16:27

2 Answers 2

up vote 16 down vote accepted

Remarks

The picture looks a lot, like it was done using Inkscape (I think, I can tell because of the arrows).

I recreated your drawing using the almighty tikz.

Implementation

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}[every path/.style={}]
    \begin{scope}
        \shade[right color=green,left color=white,opacity=0.7] (-0.5,-0.5) rectangle (0,6.5);
        \node[rotate=90,above] at (0,3) {Non-Negative Gold};
        \shade[top color=yellow,bottom color=white,opacity=0.7] (-0.5,-0.5) rectangle (8.5,0);
        \node[below] at (4,0) {Non-Negative Bills};
        \shade[left color=red,bottom color=red,right color=white,opacity=0.5] (-0.5,5.5) -- (8.5,3) -- (8.5,6.5) -- (-0.5,6.5) -- cycle;
        \path (-0.5,5.5) -- node[pos=0.23,sloped,above] {Volume Constraint} (8.5,3);
        \shade[left color=blue,right color=white,opacity=0.5] (2.5,6.5) -- (8.5,6.5) -- (8.5,0) -- (5,0) -- cycle;
        \path (5,0) -- node[pos=0.3,sloped,above] {Weight Constraint} (2.5,6.5);
        \node[text width=7em,align=center] at (2,2) {Feasible Region of the Linear Relaxation};
        \draw[->] (-0.5,0) -- (8.5,0) node[below] {Gold bars};
        \draw[->] (0,-0.5) -- (0,6.5) node[above] {Bill stacks};
        \node[rotate=-45,above,text width=9em,align=center] at (7.25,5.25) {Level Curves of the Objective Function};
        \path[clip] (-0.5,-0.5) rectangle (8.5,6.5);
        \foreach \i in {0.5,3,...,13} {
            \draw[help lines] (-0.5,\i) -- +(-45:15);
        }
    \end{scope}
    \draw[very thick,->] (9,3.25) -- node[above,text width=4cm,align=center] {\Large\bfseries Add Integrality Constraints} (13,3.25);
    \begin{scope}[shift={(14,0)}]
        \shade[right color=green,left color=white,opacity=0.7] (-0.5,-0.5) rectangle (0,6.5);
        \shade[top color=yellow,bottom color=white,opacity=0.7] (-0.5,-0.5) rectangle (8.5,0);
        \shade[left color=red,bottom color=red,right color=white,opacity=0.5] (-0.5,5.5) -- (8.5,3) -- (8.5,6.5) -- (-0.5,6.5) -- cycle;
        \shade[left color=blue,right color=white,opacity=0.5] (2.5,6.5) -- (8.5,6.5) -- (8.5,0) -- (5,0) -- cycle;
        \draw[->] (-0.5,0) -- (8.5,0) node[below] {Gold bars};
        \draw[->] (0,-0.5) -- (0,6.5) node[above] {Bill stacks};
        \foreach \i in {0,1,...,6.5} {
            \draw[help lines] (-0.5,\i) -- (8.5,\i);
        }
        \foreach \i in {2,4,...,8.5} {
            \draw[help lines] (\i,6.5) -- (\i,-0.5);
        }
        \foreach \i in {0,1,...,5} {
            \node[draw,cross out,label={left:\i}] at (0,\i) {};
        }
        \foreach \i in {0,1,...,4} {
            \node[draw,cross out] at (2,\i) {};
        }
        \foreach \i in {0,1,...,2} {
            \node[draw,cross out] at (4,\i) {};
        }
        \foreach \i in {0,2,...,6} {
            \node[below] at (\i,0) {\pgfmathparse{int(\i/2)}\pgfmathresult};
        }
        \node[very thick,draw=black,fill=white,rectangle,rounded corners,text width=8em,align=center] at (6,5) {Feasible solutions of the integer program are the crosses};
    \end{scope}
\end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer
    
+1 for "I can tell because of the arrows." –  Ilmari Karonen Dec 1 '13 at 20:42
    
@IlmariKaronen Thank you. Actually, that's not meant to be a joke. Personally I think, that I can spot differences between arrows produced by Inkscape, TikZ and Metapost. –  Henri Menke Dec 1 '13 at 22:36

Just a starting point with PSTricks.

\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-plot}
\usepackage{pst-slpe}

\begin{document}
\psset{xunit=2cm}
\begin{pspicture}(-.5,-.5)(4.5,6.5)
    \psgrid[gridcolor=lightgray,subgriddiv=1,gridlabels=0](-.5,-.5)(4,6)
    \bgroup
        \psset{linestyle=none,linewidth=0,fillstyle=slope,slopesteps=500,fading}
        \psframe[slopebegin=white,slopeend=green](-.5,-.5)(0,6)
        \psframe[slopebegin=white,slopeend=yellow,slopeangle=90](-.5,-.5)(4,0)
        \pspolygon[slopebegin=red,slopeend=red!50!white,startfading=0,endfading=.7](-.5,5.8)(-.5,6)(4,6)(4,2)
    \egroup
    \psaxes[ticks=none]{->}(0,0)(-.5,-.5)(4,6)[\parbox{2cm}{\scriptsize Gold Bars},-90][\parbox{3cm}{\scriptsize \centering Bill\\ Stacks},90]
    \bgroup
        \psset{dotstyle=x,dotscale=2}
        \multido{\i=0+1}{6}{\psdots(0,\i)}
    \egroup
\end{pspicture}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.