看起来很漂亮!我会喜欢的!看看http://www.science4all.org/le-nguyen-hoang/integer-programming/
有人知道什么软件可以画这种图形吗?我有兴趣学习一下。
谢谢!
答案1
评论
这张照片看起来很像是用Inkscape(我想,我可以通过箭头看出来)。
我使用万能的重新创建了你的绘图tikz
。
执行
\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}
输出
答案2
这只是 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}