如何更改 pgfplots 散点图中标记标签的字体大小?我尝试过 label style={font=\small}
以及\pgfplotsset
添加scatter/@pre marker code/.code={font=\small}
,但无济于事。
MWE 如下:
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$a$,
ylabel=$b$
]
\addplot[blue,mark=*,mark options={fill=blue},nodes near coords,only marks,
point meta=explicit symbolic] table[meta=label] {
x y label
100 150 1
200 180 2
};
\end{axis}
\end{tikzpicture}
\end{document}
谢谢!
答案1
您必须every node near coord/.append style={font=\small}
在选项中使用axis
或addplot
或\pgfplotsset
。
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$a$,
ylabel=$b$,
every node near coord/.append style={font=\small}
]
\addplot[blue,mark=*,mark options={fill=blue},nodes near coords,only marks,
point meta=explicit symbolic] table[meta=label] {
x y label
100 150 1
200 180 2
};
\end{axis}
\end{tikzpicture}
\end{document}