设置小刻度,保持无边框

设置小刻度,保持无边框

我想要一个边缘没有网格线的网格,因此我将以下代码设置为域和范围为奇数。但是,设置次要刻度时,您可以在图片中看到次要刻度出现在顶部,

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{intersections}
\usetikzlibrary{patterns}
\usetikzlibrary{arrows}
\begin{document}


\begin{enumerate}
    \item Find the slope and $y$-intercept of this graph.\\
    \begin{tikzpicture}[E/.style={font=\small,text=black, sloped, pos=0.75}]
    \begin{axis}[axis line style=thin,
    axis x line=center,
    axis y line=center,
    ytick={-6,-4,...,6},
    xtick={-6,-4,...,6},
    ymin=-7, ymax=7, xmin=-7, xmax=7, xlabel=$x$, ylabel=$y$, grid=both,minor tick num=3, y post scale=1]
    \addplot[name path=A,domain=-7:7, samples=100, thick] { 3*x/4-3} node[E,above] {};
    %\addplot[name path global=line1, color=blue!50, thick, domain=-7:9]{5-3*x/5};
    \end{axis}
\end{tikzpicture}
\end{document}

这是我的结果的图像。图片1

答案1

ytick我会扩大到的范围ytick={-8,-6,...,8},然后使用来限制它们的出现ytickmin=-6.9,ytickmax=6.9

在此处输入图片描述

代码:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.14}% <- added, current version is 1.14
\usetikzlibrary{intersections}
%\usetikzlibrary{patterns}
%\usetikzlibrary{arrows}
\begin{document}
\begin{enumerate}
  \item Find the slope and $y$-intercept of this graph.\\
    \begin{tikzpicture}[E/.style={font=\small,text=black, sloped, pos=0.75}]
      \begin{axis}[
          axis line style=thin,
          axis lines=center,
          %%%
          ytick={-8,-6,...,8},
          ymin=-7, ymax=7,
          ytickmin=-6.9,ytickmax=6.9,
          xtick={-8,-6,...,8},
          xmin=-7, xmax=7,
          xtickmin=-6.9,xtickmax=6.9,
          %%%
          xlabel=$x$,
          ylabel=$y$,
          grid=both,
          minor tick num=3,
          y post scale=1
      ]
        \addplot[name path=A,domain=-7:7, samples=100, thick] { 3*x/4-3} node[E,above] {};
      \end{axis}
    \end{tikzpicture}
\end{enumerate}
\end{document}

相关内容