有人能帮我画出这个 xy 轴的最小示例吗?我在论坛上找不到类似的东西。
轴应为黑色,但其后面的网格应为灰色,虚线。如果轴也比网格稍粗一点就好了。
答案1
和TiKZ
:
\documentclass[tikz,border=2mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[help lines, color=gray!30, dashed] (-4.9,-4.9) grid (4.9,4.9);
\draw[->,ultra thick] (-5,0)--(5,0) node[right]{$x$};
\draw[->,ultra thick] (0,-5)--(0,5) node[above]{$y$};
\end{tikzpicture}
\end{document}
答案2
为何pgfplots
被排除在外?
\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[grid=both,ymin=-5,ymax=5,xmax=5,xmin=-5,xticklabel=\empty,yticklabel=\empty,
minor tick num=1,axis lines = middle,xlabel=$x$,ylabel=$y$,label style =
{at={(ticklabel cs:1.1)}}]
\end{axis}
\end{tikzpicture}
\end{document}
答案3
答案4
这是一个相当通用的元帖子制作网格的方法。点击链接查看 Metapost 简介以及如何在 LaTeX 文档中使用此代码。
prologues := 3;
outputtemplate := "%j%c.eps";
beginfig(1);
u = 1cm;
ymax = xmax = 4.75;
xmin = ymin = -4.75;
path xx, yy;
xx = ((xmin,0) -- (xmax,0)) scaled u;
yy = ((0,ymin) -- (0,ymax)) scaled u;
drawoptions(dashed evenly scaled .5 withcolor .7 white);
for i = ceiling ymin upto floor ymax: draw xx shifted (0,i*u); endfor
for i = ceiling xmin upto floor xmax: draw yy shifted (i*u,0); endfor
drawoptions(withpen pencircle scaled .7);
xx := xx scaled 1.05;
yy := yy scaled 1.05;
drawarrow xx;
drawarrow yy;
drawoptions();
label.rt (btex $x$ etex, point infinity of xx);
label.top(btex $y$ etex, point infinity of yy);
endfig;
end.