将网格放在图形后面

将网格放在图形后面

有人能告诉我如何使用以下代码在我绘制的图形中放置网格 [(-6,-6) 到 (6,6)]。另外,如果您注意到标签“y1”和“y2”附近的箭头,它们真的很小,那么我该如何增加它们的尺寸呢?

所附图片正是我想要的。提前致谢。我想要的是我画的

\documentclass[11pt]{article}
\usepackage{tkz-euclide}

\begin{document}
\begin{figure}[h!]
\centering
\resizebox{7cm}{7cm}{
    \begin{tikzpicture}

    \draw[->] (-6,0)--(7,0);
    \node[scale=2, right] at (7,0) {$y_1$};
    \draw[->] (0,-6)--(0,7);
    \node [scale=2, above] at (0,7) {$y_2$};
    \draw (2,6)--(2,2)--(6,2);
    \draw (-6,2)--(-2,2)--(-2,6);
    \draw (-6,-2)--(-2,-2)--(-2,-6);
    \draw (2,-6)--(2,-2)--(6,-2);
    \node [scale=2, right] at (6,2) {$b-a$};
    \node [scale=2, right] at (6,4) {$b$};
    \node [scale=2, right] at (4,4) {$c_0$};
    \node [scale=2, left] at (-4,4) {$c_1$};
    \node [scale=2, left] at (-4,-4) {$c_2$};
    \node [scale=2, right] at (4,-4) {$c_3$};

    \draw (4,4)--(4,4);
    \filldraw (4,4) circle (3pt);
    \draw (-4,4)--(-4,4);
    \filldraw (-4,4) circle (3pt);
    \draw (4,-4)--(4,-4);
    \filldraw (4,-4) circle (3pt);
    \draw (-4,-4)--(-4,-4);
    \filldraw (-4,-4) circle (3pt);

\end{tikzpicture}
}
\end{figure}
\end{document}

答案1

grid可用于绘制网格。arrows.meta提供各种可配置的箭头提示。但scale就我所见,这段代码中确实没有什么值得推荐的奇怪用法,我建议考虑消除它,而不是像我在这里所做的那样添加进一步的缩放。我还删除了什么都不做的代码,例如从一个点到自身画一条线并稍微压缩它。

\documentclass[tikz, border=5pt, multi]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[>={Stealth[scale=2]}]
  \draw [thin, draw=gray!50!blue!50] (6,6) grid (-6,-6);
  \draw [->] (-6,0)--(7,0);
  \node[scale=2, right] at (7,0) {$y_1$};
  \draw [->] (0,-6)--(0,7);
  \node [scale=2, above] at (0,7) {$y_2$};
  \draw (2,6)--(2,2)--(6,2) (-6,2)--(-2,2)--(-2,6) (-6,-2)--(-2,-2)--(-2,-6)  (2,-6)--(2,-2)--(6,-2);
  \node [scale=2, right] at (6,2) {$b-a$};
  \node [scale=2, right] at (6,4) {$b$};
  \node [scale=2, right] at (4,4) {$c_0$};
  \node [scale=2, left] at (-4,4) {$c_1$};
  \node [scale=2, left] at (-4,-4) {$c_2$};
  \node [scale=2, right] at (4,-4) {$c_3$};
  \filldraw (4,4) circle (3pt) (-4,4) circle (3pt) (4,-4) circle (3pt) (-4,-4) circle (3pt);
\end{tikzpicture}
\end{document}

网格和比例箭头

相关内容