如何使节点上的标签变小(pgfplots)

如何使节点上的标签变小(pgfplots)

我想让图表中的节点(如下图)具有较小的标签(即较小的字体),因为目前我的图表在编译时会使所有节点相互碰撞。我该怎么做?

\begin{figure}[H]
    \centering
        \begin{tikzpicture}
        \begin{axis}[grid=both,
                  xmin=-1, xmax=2,ymin=-2, ymax=2,
                  axis lines=middle,
                  enlargelimits]
            \addplot[black] (2,0) node[above] {$dx$};
            \addplot[black] (0,2.2) node[below right] {$df$};
            \addplot[blue,samples=1000,domain=0:15] {0.7-0.7*x^2-0.5*sin(180*10*x/pi)};
            \node[label={135:{(0.0,0)}}, circle, fill, inner sep = 1pt] at (axis cs:0.0,0) {};
            \node[label={135:{(0.285,0)}}, circle, fill, inner sep = 1pt] at (axis cs:0.285,0) {};
            \node[label={135:{(0.66,0)}}, circle, fill, inner sep = 1pt] at (axis cs:0.66,0) {};
            \node[label={135:{(0.934,0)}}, circle, fill, inner sep = 1pt] at (axis cs:0.934,0) {};
            \node[label={45:{(1.218,0)}}, circle, fill, inner sep = 1pt] at (axis cs:1.218,0) {};
        \end{axis}
        \end{tikzpicture}
        \caption{The graph of equation \ref{fig:eqN}, $\frac{df}{dx}= r - rx^2 -\frac{1}{2}\sin{nx}\mbox{, for }r = 0.7, n = 10$}
        \label{fig:logistic8}
    \end{figure}

在此处输入图片描述

答案1

您不能将坐标文本设置得太小,以免它们重叠。除了减小字体大小外,还可以旋转字体:

\documentclass[border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}

\begin{document}
    \begin{tikzpicture}[
every label/.style = {font=\tiny, inner sep=2pt, rotate=30, anchor=west},
        dot/.style = {circle, fill, inner sep = 1pt}
                        ]
\begin{axis}[
    axis lines=middle,
    grid=both,
    xlabel=$dx$,
    ylabel=$df$,
    xmin=-1, xmax=2,
    ymin=-2, ymax=2,
    ticklabel style = {font=\footnotesize},
    enlargelimits]
    \addplot[blue,samples=1000,domain=0:15] {0.7-0.7*x^2-0.5*sin(180*10*x/pi)};
    \node[label=135:{(0.0,0)}, dot] at (0.0,0) {};
    \node[label=135:{(0.285,0)}, dot] at (0.285,0) {};
    \node[label=135:{(0.66,0)}, dot] at (0.66,0) {};
    \node[label=135:{(0.934,0)}, dot] at (0.934,0) {};
    \node[label=135:{(1.218,0)}, dot] at (1.218,0) {};
\end{axis}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容