我觉得这是一个非常简单的问题,但到目前为止我还没有找到一个简单的答案。如何将下图中的 x 标签从轴的右端移动到左端?
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
width=0.9\linewidth,height=0.7\linewidth,
xlabel=$x$,ylabel=$(x+1)^2$,
xmin=-2.1,xmax=0.05,
ymin=-0.05,ymax=1.1,
xtick={-2,-1,0},ytick={0,0.5,1},
axis lines=center,
thick,every tick/.style={thin}]
\addplot[blue,samples=100] {(x+1)^2};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
一种可能性是:
xlabel style={at={(0,0)},above right,yshift=10pt}
代码:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
width=0.9\linewidth,height=0.7\linewidth,
xlabel=$x$,ylabel=$(x+1)^2$,
xmin=-2.1,xmax=0.05,
ymin=-0.05,ymax=1.1,
xtick={-2,-1,0},ytick={0,0.5,1},
axis lines=center,
thick,every tick/.style={thin},
xlabel style={at={(0,0)},above right,yshift=10pt}
]
\addplot[blue,samples=100] {(x+1)^2};
\end{axis}
\end{tikzpicture}
\end{document}