我想将它从右上角移到左上角,但我尝试了各种方法都没有成功。
\begin{figure}[H]
\caption{Stress-Strain Curve, Mix C}
\begin{tikzpicture}
\begin{axis}[xlabel=Strain ,ylabel=Stress (psi), width=12cm, height=8cm]
\addplot+[smooth,color=blue,mark=o]coordinates{
(0.000001, 11)
(0.000045, 38)
(0.000123, 85)
(0.000231, 150)
(0.000371, 230)
(0.000535, 321)
(0.000709, 419)
(0.000897, 524)
(0.001094, 632)
(0.001294, 745)
(0.001502, 862)
(0.001713, 981)
(0.001929, 1103)
(0.002146, 1226)
(0.002365, 1351)
(0.002585, 1478)
(0.002806, 1605)
(0.00303, 1733)
(0.003256, 1861)
(0.003408, 1945)
};
\addlegendentry{Specimen C19E-1}
答案1
可以通过以下方式调整图例位置
every axis legend/.append style={}.
因此
every axis legend/.append style={at={(0.0,1.03)}, anchor=south west}
你得到:
或者,使用
every axis legend/.append style={at={(0.03,0.97)}, anchor=north west}
你得到:
代码:
\documentclass[tikz, border=2pt]{standalone}
\usepackage{pgfplots}
%% if you want to change this globally
%\pgfplotsset{every axis legend/.append style={
% at={(0.0,1.03)},
% anchor=south west}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel=Strain ,ylabel=Stress (psi), width=12cm, height=8cm,
every axis legend/.append style={
at={(0.,1.03)},
anchor=south west}
]
\addplot+[smooth,color=blue,mark=o]coordinates{
(0.000001, 11)
(0.000045, 38)
(0.000123, 85)
(0.000231, 150)
(0.000371, 230)
(0.000535, 321)
(0.000709, 419)
(0.000897, 524)
(0.001094, 632)
(0.001294, 745)
(0.001502, 862)
(0.001713, 981)
(0.001929, 1103)
(0.002146, 1226)
(0.002365, 1351)
(0.002585, 1478)
(0.002806, 1605)
(0.00303, 1733)
(0.003256, 1861)
(0.003408, 1945)
};
\addlegendentry{Specimen C19E-1}
\end{axis}
\end{tikzpicture}
\end{document}