有没有办法让 中的网格\psgrid
看起来与 中的网格相同tikzpicture
?
\documentclass[12pt,pstricks]{exam}
\usepackage{tikz}
\usepackage{pst-all}
\begin{document}
\psset{unit=0.5cm}
\begin{pspicture}(12,14)
\psgrid[gridcolor=red,subgridcolor=green,gridlabels=0](0,0)(10,12)
\psaxes[Dx=2,Dy=4,showorigin=false]{->}(0,0)(0,0)(11,13)
\psplot{0.5}{9.5}{36 x mul sin 5 mul 6 add}
\end{pspicture}\\\vspace{1cm}
\begin{tikzpicture}[scale=0.5]
\draw [ultra thick,<->] (0,13) -- (0,0) -- (11,0);
\foreach \y in {2,4,...,12}{\draw [color=red] (0,\y) -- (10,\y);}
\foreach \x in {2,4,...,10}{\draw [color=red] (\x,12) -- (\x,0) node [below,color=black] {\x};}
\foreach \y in {1,3,...,11}{\draw [color=green] (0,\y) -- (10,\y);}
\foreach \y in {4,8,12}{\draw (0,\y) node [left] {\y};}
\foreach \x in {0.5,1,1.5,2.5,3,3.5,4.5,5,5.5,6.5,7,7.5,8.5,9,9.5}{\draw [color=green] (\x,0) -- (\x,12);}
\draw [domain=0.5:9.5,samples=100,thick,<->] plot (\x,{5*sin(36*\x)+6});
\end{tikzpicture}
\end{document}
答案1
\psaxes
也可以通过代替 来完成\psgrid
。实际上,它需要调用\psaxes
两个不同标签距离的 。
\documentclass[12pt]{exam}
\usepackage{pst-all}
\begin{document}
\psset{unit=0.5cm}
\begin{pspicture}(-1,-1)(12,14)
\psaxes[Dx=2,Dy=4,showorigin=false,ticksize=0,]{->}(0,0)(11,13)% without ticks
\psaxes[Dy=2,Dx=2,showorigin=false,labels=none,% with ticks
yticksize=0 10,xticksize=0 12,tickcolor=red,
subticksize=1,ysubticks=2,xsubticks=4,subtickcolor=green,](0,0)(10,12)
\psplot[algebraic,arrows=<->]{0.5}{9.5}{5*sin(Pi/5*x)+6}
\end{pspicture}
\end{document}
答案2
这是 Ti钾z 图:
以下是 PStricks 版本:
\documentclass{article}
\usepackage{pst-plot}
\begin{document}
\psset{unit=0.5cm}
\begin{pspicture}(12,14)
\psgrid[gridcolor=red,subgridcolor=green,gridlabels=0,subgriddiv=4,gridwidth=.4pt,unit=2](0,0)(5,6)
\psaxes[Dx=2,Dy=4,showorigin=false]{->}(0,0)(0,0)(11,13)
\psplot{0.5}{9.5}{36 x mul sin 5 mul 6 add}
\end{pspicture}
\end{document}
subgriddiv=4
注意、gridwidth=.4pt
(默认为.8pt
)和的使用unit=2
。最后一个键值将网格拉长(两倍),因此我们只需要转到 坐标,(5,6)
而不是(10,12)
。