到目前为止我已经能够创作出以下情节:
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
view={80}{30},
axis equal,
hide axis
]
\addplot3[
dashed,
y domain=0:0,
samples=200,
domain=0:2*pi,
]
({cos(deg(x))},{sin(deg(x))},{0});
\addplot3[
thick,
y domain=0:0,
samples=200,
domain=0:2*pi,
]
({cos(deg(x))},{sin(deg(x))},{0.3*sin(deg(7*x))});
\addplot3[
y domain=0:0,
samples=200,
domain=0:2*pi,
]
({1+0.1*cos(deg(x))},{0.1*sin(deg(x))},{0});
\end{axis}
\end{tikzpicture}
\caption{This is just a very long sentence. I want my graph to extend through the entire space available; nonetheless, there is a white space occupied by the axis I want to remove.}
\label{fig:motion}
\end{figure}
产生以下内容(几乎正是我想要的):
我可以隐藏轴,但它们占据的空间仍然存在。我希望我的绘图能够延伸到整个可用的水平长度(并且希望能够控制它)。
我想要的最终情节如下:
我还想在每条路径中添加箭头和文本。但我的主要问题是关于大小,如果它们不是那么简单,我可以稍后在 Google 上搜索如何添加它们。
谢谢
答案1
可以通过增加 来增加宽度width
。由于您抑制了框架,因此获取全宽所需的值有点违反直觉,但可能比使用其他键更简单。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usetikzlibrary{3d,arrows.meta}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[width=1.25\textwidth,
view={80}{30},
axis equal image,
hide axis,sp/.style={smooth cycle,
samples y=0,domain=#1,
samples=101},sp/.default=0:2*pi
]
\addplot3[sp,dashed] ({cos(deg(x))},{sin(deg(x))},{0});
\addplot3[sp,thick] ({cos(deg(x))},{sin(deg(x))},{0.3*sin(deg(7*x))});
\addplot3[sp,thin] ({1+0.1*cos(deg(x))},{0.1*sin(deg(x))},{0});
\addplot3[sp=pi-0.4:pi-0.05,sharp plot,red,-{Stealth}]
({cos(deg(x))},{sin(deg(x))},{-0.1})
node[pos=0.5,font=\sffamily,below]{Magnetron};
\addplot3[sp=-0.7:-0.5,sharp plot,red,-{Stealth}]
({cos(deg(x))},{sin(deg(x))},{0.3*sin(deg(7*x))+0.1})
node[pos=0.5,font=\sffamily,above right]{Axial};
\end{axis}
\end{tikzpicture}
\caption{This is just a very long sentence. I want my graph to extend through the entire space available; nonetheless, there is a white space occupied by the axis I want to remove.}
\label{fig:motion}
\end{figure}
\end{document}
答案2
起初我以为[scale only axis]
可以处理宽度,但它仍然为绘制点的整个立方体(域)留有空间。解决这个问题的唯一方法是追溯使用\resizebox
,这也会使字体稍微大一些。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usetikzlibrary{3d,arrows.meta}
\begin{document}
\begin{figure}
\centering
\resizebox{\textwidth}{!}{\begin{tikzpicture}
\begin{axis}[scale only axis, width=\textwidth,
view={80}{30},
axis equal image,
hide axis,
sp/.style={smooth cycle,
samples y=0,domain=#1,
samples=101},sp/.default=0:2*pi
]
\addplot3[sp,dashed] ({cos(deg(x))},{sin(deg(x))},{0});
\addplot3[sp,thick] ({cos(deg(x))},{sin(deg(x))},{0.3*sin(deg(7*x))});
\addplot3[sp,thin] ({1+0.1*cos(deg(x))},{0.1*sin(deg(x))},{0});
\addplot3[sp=pi-0.4:pi-0.05,sharp plot,red,-{Stealth}]
({cos(deg(x))},{sin(deg(x))},{-0.1})
node[pos=0.5,font=\sffamily,below]{Magnetron};
\addplot3[sp=-0.7:-0.5,sharp plot,red,-{Stealth}]
({cos(deg(x))},{sin(deg(x))},{0.3*sin(deg(7*x))+0.1})
node[pos=0.5,font=\sffamily,above right]{Axial};
\end{axis}
\draw[red] (current bounding box.south west) rectangle (current bounding box.north east);
\end{tikzpicture}}
\caption{This is just a very long sentence. I want my graph to extend through the entire space available; nonetheless, there is a white space occupied by the axis I want to remove.}
\label{fig:motion}
\end{figure}
\end{document}
如果您不想改变字体大小,您可以通过两次绘图来计算所需的宽度。
请注意\redo
,\scale
和\box0
是图形局部的。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usetikzlibrary{3d,arrows.meta}
\begin{document}
\begin{figure}
\centering
\def\redo{\begin{tikzpicture}
\begin{axis}[scale only axis, width=\scale\textwidth,
view={80}{30},
axis equal image,
hide axis,
sp/.style={smooth cycle,
samples y=0,domain=#1,
samples=101},sp/.default=0:2*pi
]
\addplot3[sp,dashed] ({cos(deg(x))},{sin(deg(x))},{0});
\addplot3[sp,thick] ({cos(deg(x))},{sin(deg(x))},{0.3*sin(deg(7*x))});
\addplot3[sp,thin] ({1+0.1*cos(deg(x))},{0.1*sin(deg(x))},{0});
\addplot3[sp=pi-0.4:pi-0.05,sharp plot,red,-{Stealth}]
({cos(deg(x))},{sin(deg(x))},{-0.1})
node[pos=0.5,font=\sffamily,below]{Magnetron};
\addplot3[sp=-0.7:-0.5,sharp plot,red,-{Stealth}]
({cos(deg(x))},{sin(deg(x))},{0.3*sin(deg(7*x))+0.1})
node[pos=0.5,font=\sffamily,above right]{Axial};
\end{axis}
\end{tikzpicture}}%
\sbox0{\def\scale{1}\redo}% get width for scale=1
\pgfmathsetmacro{\scale}{\textwidth/\wd0}% recompute scale
\redo
\caption{This is just a very long sentence. I want my graph to extend through the entire space available; nonetheless, there is a white space occupied by the axis I want to remove.}
\label{fig:motion}
\end{figure}
\end{document}