因此,我尝试将此图置于图像中显示的小段落正下方的中心。对于此图,我尝试让两个轴具有相同的缩放比例,但我的域和范围不起作用。出于某种原因,我似乎也无法将图例移动到正确的位置。如果能得到一点帮助,我将不胜感激!
\documentclass{article}
When studying the surface itself, these results cohere with its symmetrical properties; Through projection upon the $xy$plane, the surface's footprint is defined as a two dimensional semi-circle with the equation $y=\sqrt{1-x^2}$
\begin{document}
\begin{tikzpicture}
\begin{center}
\begin{axis}[
axis lines = center,
xlabel = \(x\),
ylabel = {\(y\)},
]
%Below the red parabola is defined
\addplot [
y=-0.25:2,
domain=-2:2,
samples=100,
color=red,
]
{(1-x^2)^0.5};
\addlegendentry{\(x^2 - 2x - 1\)}
legend pos: northwest
\end{axis}
\end{center}
\end{tikzpicture}
\end{document}
答案1
您的环境center
位于错误的位置。它必须是完整的图片,而不仅仅是axis
环境:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
When studying the surface itself, these results cohere with its symmetrical properties; Through projection upon the $xy$plane, the surface's footprint is defined as a two dimensional semi-circle with the equation $y=\sqrt{1-x^2}$
\begin{center}
\begin{tikzpicture}
\begin{axis}[
axis lines = center,
xlabel = \(x\),
ylabel = {\(y\)},
]
%Below the red parabola is defined
\addplot [
y=-0.25:2,
domain=-2:2,
samples=100,
color=red,
]
{(1-x^2)^0.5};
\addlegendentry{\(x^2 - 2x - 1\)}
legend pos: northwest
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
编辑: 轴选项通常收集在它的前导点中,作为图像主体的一部分。因此完整的图像应该是:
\begin{tikzpicture}
\begin{axis}[
axis lines = center,
xlabel = \(x\),
ylabel = {\(y\)},
enlargelimits=0.2,
legend pos=north east
]
\addplot [
domain=-1:1,
samples=100,
color=red,
]
{(1-x^2)^0.5};
\legend{\(x^2 - 2x - 1\)}
\end{axis}
\end{tikzpicture}
figure
但是,您可以按如下方式将图像插入浮动环境中:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
When studying the surface itself, these results cohere with its symmetrical properties; Through projection upon the $xy$plane, the surface's footprint is defined as a two dimensional semi-circle with the equation $y=\sqrt{1-x^2}$
\begin{figure}[ht]
\centering
\begin{tikzpicture}
\begin{axis}
...
\end{axis}
\end{tikzpicture}
\end{figure}
\caption{My image}
\label{fig:ilustration}
\end{document}
答案2
您需要放置您的tikzpicture
内部figure
环境。
就这样
\begin{figure}[h]
\begin{center}
\begin{tikzpicture}[scale=2]
\draw[help lines] (0,0) grid (2,3);
\draw[<->] (0,3.1) -- (0,0) -- (2.1,0);
\draw[green,fill=yellow] (1,1) circle [radius=0.5];
\draw[red] (0,0) -- (0,1);
\draw[red] (0,1) -- (1,1) -- (2,3);
\draw[domain=-1:2] plot (\x, \x*\x + 2);
\node[below] at (1,1) {\tiny Text $R=0,5$};
\end{tikzpicture}
\caption{TikZ centered}
\end{center}
\end{figure}