我绘制了散点图pgfplots
:
使用此代码:
\begin{figure}[H]
\centering
\begin{tikzpicture}
\pgfplotsset{ticks=none}
\begin{axis}[ymin=0, ymax=10.5, xmin=0, xmax=10.5,axis x line=bottom,axis y line=left,font=\scriptsize,scatter/use mapped color={draw=black},xlabel={$x$},ylabel={$y$}]
\addplot[scatter,only marks] coordinates {%
(0.5,1) (1,2) (2,2) (3,3) (4,3) (5,5) (6,4) (6,6) (7,8) (8,7) (9,9) (10,9)
};
\end{axis}
\end{tikzpicture}
\end{figure}
如何使$x$
和分别$y$
位于轴的右侧x
和轴的顶部y
?
答案1
您可以使用xlabel style
并ylabel style
喜欢
xlabel style={at={(1,0)},right},
ylabel style={at={(0,1)},above,rotate=-90},
代码:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\pgfplotsset{ticks=none}
\begin{axis}[ymin=0, ymax=10.5, xmin=0, xmax=10.5,axis x line=bottom,axis y line=left,font=\scriptsize,scatter/use mapped color={draw=black},xlabel={$x$},ylabel={$y$},
xlabel style={at={(1,0)},right},
ylabel style={at={(0,1)},above,rotate=-90},
]
\addplot[scatter,only marks] coordinates {%
(0.5,1) (1,2) (2,2) (3,3) (4,3) (5,5) (6,4) (6,6) (7,8) (8,7) (9,9) (10,9)
};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}