pgfplots:縮放圖例字體大小

pgfplots:縮放圖例字體大小

有一些貼文詢問並回答如何縮放圖例字體大小。例如,

然而,這些依賴於使用以下命令:

 legend style={font=\tiny}

我想使用命令scale = 0.5(或類似命令)重新縮放圖例字體(甚至整個圖例),類似於重新縮放節點的方式。我在這裡問了一個關於重新縮放軸標籤字體大小的類似問題,但我無法獲得適用於圖例的相同解決方案(也就是說,簡單地更改font=style=似乎不起作用。

我在下面附上一個最小的例子:

\documentclass{standalone}

\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[legend image post style={mark=*}]

\addplot+[mark=*, color=blue, very thin, only marks, mark size=0.8pt]{-x*(x-2)};
\addlegendentry{Measurement}
\end{axis}
\end{tikzpicture}

\end{document}

產生

圖例範例

答案1

就像是:

[...]
    \begin{axis}[legend style={nodes={scale=0.5, transform shape}}, 
        legend image post style={mark=*}]
[...]

圖例的「樣式」nodes將套用於為產生圖例框而建立的所有節點。

上述程式碼片段的螢幕截圖

(順便說一句,您應該\pgfplotsset{compat=1.9}在程式碼中添加 a ,或至少添加類似的內容,以避免將來出現刻度標籤問題)。

完整程式碼(供參考):

\documentclass{standalone}

\usepackage{tikz}
\usepackage{pgfplots}\pgfplotsset{compat=1.9}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[legend style={nodes={scale=0.5, transform shape}}, 
        legend image post style={mark=*}]

\addplot+[mark=*, color=blue, very thin, only marks, mark size=0.8pt]{-x*(x-2)};
\addlegendentry{Measurement}
\end{axis}
\end{tikzpicture}

\end{document}

相關內容