x 轴和 y 轴的刻度相同

x 轴和 y 轴的刻度相同

我想在 x 轴和 y 轴上设置相同的比例,您知道这段代码有什么问题吗?

以下是代码

\begin{tikzpicture}[>=latex]
\begin{axis}[axis x line=center,
             axis y line=center,
             xlabel style={below right},
            ylabel style={above left},
            ytick=\empty,
            xtick=\empty,
           ]
                    \addplot[name path=F,blue,domain={-2:5}] {x^3-3*x} node[pos=.8, above]{$f$};
          \addplot[name path=G,green,domain={-2:5}] {6*x}node[pos=.1, below]{$g$};
          \addplot[pattern=north west lines, pattern color=brown!50]fill between[of=F and G, soft clip={domain=-1:4}];

    \end{axis}
\end{tikzpicture}

答案1

您可能需要重新调整软剪辑区域和节点位置,但如果您希望轴均匀缩放,则可以添加axis equal键。

%\usetikzlibrary{intersections, pgfplots.fillbetween, patterns}
\begin{tikzpicture}[>=latex]
    \begin{axis}[axis x line=center,
                 axis y line=center,
                 xlabel style={below right},
                 ylabel style={above left},
                 ytick=\empty,
                 xtick=\empty,
                 axis equal % <---
           ]
          \addplot[name path=F,blue,domain={-2:5}] {x^3-3*x} node[pos=.8, above]{$f$};
          \addplot[name path=G,green,domain={-2:5}] {6*x}node[pos=.1, below]{$g$};
          \addplot[pattern=north west lines, pattern color=brown!50]fill between[of=F and G, soft clip={domain=-1:4}];
    \end{axis}
\end{tikzpicture}

相关内容