答案1
你可以使用PGFPlots,它能用相对较短的代码提供出色、灵活的图表。
这是一些可以让你开始的东西。我有点不明白你输入的意思,所以它可能不正确,但你应该能够根据自己的需要进行编辑。
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{amssymb}
\pgfplotsset{width=12cm,compat=1.12}
\begin{document}
%!tikz source begin
\begin{tikzpicture}
\tikzset{
every pin/.style={fill=yellow!50!white,rectangle,rounded corners=3pt,font=\tiny},
small dot/.style={fill=black,circle,scale=0.3}
}
\begin{axis}[
y label style={rotate=-90},
%title=My title,
ylabel = $\gamma_g^e$,
xlabel = {n=$|V(P_N)|$},
ymin=0,xmin=0,
ymax=15,xmax=19
]
\addplot[
red,
domain=2:18,
samples=17,
]
{floor((x+2)/2};
\addplot[blue, ] coordinates{(2,4) (6,4) (7,5)};
\addplot[
blue,
domain=7:18,
samples=13,
]
{floor(2*(x/3)+1}; % Original input{ceil(2*(x/3)};
\node[small dot,pin=-30:{$\gamma_g^e(P_6\Box P_2) = \gamma_g^e(P_6)\gamma_g^e(P_2)$}] at (6,4) {};
\legend{$\gamma_g^e(P_6\Box P_2)$,$\gamma_g^e(P_n)\gamma_g^e(P_2)$}
\end{axis}
\end{tikzpicture}
\end{document}
答案2
这是 Metapost 中的一个尝试。你可以在 Metapost 上找到更多内容这里。
您需要对其进行编译mpost -tex=latex
才能使用提供\Box
符号的 LaTeX 包。
我把剩余的标签和箭头留给你去做:-)
prologues := 3;
outputtemplate := "%j%c.eps";
beginfig(1);
% unit of meaurement
u := 7mm;
% axes
path xx, yy;
xx = (left -- 19 right) scaled u;
yy = xx rotated 90;
for i=1 upto 18:
draw (down--up) shifted (i*u,0); label.bot(decimal i, (i*u,-2));
draw (left--right) shifted (0,i*u); label.lft(decimal i, (-2,i*u));
endfor
drawarrow xx; label.rt(btex $x$ etex, point 1 of xx);
drawarrow yy; label.top(btex $y$ etex, point 1 of yy);
% functions
vardef f(expr x) = floor ((x+2)/2) enddef;
vardef g(expr x) = 2 * if x<4: 2 else: ceiling (x/3) fi enddef;
% curves
path ff, gg;
ff = ( (2,f(2)) for t=3 upto 18: -- (t,f(t)) endfor ) scaled u;
gg = ( (2,g(2)) for t=3 upto 18: -- (t,g(t)) endfor ) scaled u;
draw ff withcolor .67 red;
for t=0 upto length ff: draw fullcircle scaled 4 shifted point t of ff; endfor
draw gg withcolor .73 blue;
for t=0 upto length gg: draw fullcircle scaled 4 shifted point t of gg; endfor
% labels
verbatimtex
\documentclass{article}
\usepackage{latexsym}
\begin{document}
etex
z0 = (6u,4u); % point of intersection
z1 = (7u,2u);
label.rt(btex $\gamma_g^e(P_6\Box P_2) = \gamma_g^e(P_6)\gamma_g^e(P_2)$ etex, z1);
drawarrow z1 .. z0 {dir 100} cutafter fullcircle scaled 8 shifted z0;
endfig;
答案3
您可以看看MetaPost
。由于我暂时无法发表评论,因此我必须通过 Answer 发送。我的数学教授为 Latex 制作了一个特殊的 MetaPost 包来创建图表 (repere.mp)。文档是法语的(抱歉):http://mirrors.ibiblio.org/CTAN/graphics/metapost/contrib/macros/repere/repere-doc.pdf
答案4
这些函数是阶跃函数。下面是pstricks
显示其图形的代码:
\documentclass[x11names, border=3pt]{standalone}
\usepackage{pst-plot}
\usepackage{auto-pst-pdf}
\begin{document}
\psset{ algebraic, arrowinset=0.2, arrowsize=3.5pt, arrowlength=1.5, linejoin=1,unit=0.6, dimen=inner}
\everypsbox{\ensuremath}
\begin{pspicture*}(-2,-2)(20, 15)
{\psset{linewidth=1.2pt, linecolor=DarkSeaGreen3, plotpoints=1000, dotstyle =Bo}
\psline[showpoints](2,4)(3,4)(4,4)
\psplot{4}{18}{2*ceiling(x/3)}
\multido{\iy=4+2, \in =3+3}{5}{\multido{\ix=\in+1}{4}{\psdots(\ix,\iy)}}
\psset{linecolor=DarkOrange1}
\psplot{2}{18}{floor((x + 2)/2)}
\multido{\iy=2+1, \in=2+2}{8}{\multido{\ix=\in+1}{3}{\psdots(\ix,\iy)}}
\psdot(18,10)}%
\psset{linecolor=SlateGray3, tickcolor=SlateGray3, ticksize=0 3pt, showorigin=false}
\psaxes[arrows=->, labelFontSize =\scriptstyle,]{->}(19.95, 15)[x, -120][y, -140]
\psaxes[arrows=-> , labels=none, ticks=none](-2,-2)
\uput[dl](0,0){O}
\end{pspicture*}
\end{document}