我在 TikZ 上创建了一个图形,它被外框裁剪了。是否可以调整其大小以显示整个图形?图像和代码位于以下 URL 上。
图像:https://i.stack.imgur.com/yEIlq.jpg
代码:[编辑]
\begin{figure}[h]
\centering
\label{fig:pendulum}
\begin{tikzpicture}[thick,>=latex,->]
\vspace{10in}
\clip(-4.6, -1.7) rectangle (4.6, 4.6);
% Trajectory projection
\draw[dashed] (0,0) circle (4.2cm);
\filldraw[white] (-4.6, -4.6) rectangle (4.6,0);
\filldraw[white] (-4.6, 0) rectangle (0, 4.6);
% Bar
\draw[double distance=5mm, -] (3.15, 2.8) -- (0, 7);
\draw[double distance=5mm, -] (0,0) -- (3.2, 3.2);
% Motor
\draw[fill=white] (1.2,-1.0) -- (.5,0) arc(180:360:-0.5) -- (-1.2, -1.0) -- cycle;
\draw[draw=black,fill=white] (0, 0) circle circle (.15cm);
% Wheels
\draw (0.7, -1.2) circle (2mm);
\draw (-0.7, -1.2) circle (2mm);
% Base
\draw[pattern=north east lines] (-1.7, -1.6) rectangle (1.7, -1.4);
% Joints
\draw[draw=black,fill=white] (0, 0) circle circle (.15cm);
\draw[draw=black,fill=white] (3, 3) circle circle (.15cm);
\draw [dashed, --] (0, 0) -- (2, 2);
\draw [dashed, --] (0, 0) -- (0, 2);
\draw [dashed, --] (3, 3) -- (3, 5);
\draw [dashed, --] (3, 3) -- (0, 7);
% Axis
\draw[->] (2.6, 0) -- (3.6,0) node[below]{\texttt{x}};
\draw[->] (2.6, 0) -- (2.6, 1) node[above]{\texttt{y}};
}%
% Angle
\draw[thick, -] (0.7, 0.7) arc (45:90:1);
\node at (.5, 1.5) {\Large $\theta_1$};
\draw[thick, -] (3, 3.7) arc (90:135:0.6);
\node at (2.7, 4.6) {\Large $\theta_2$};
\end{tikzpicture}
\caption{Desenho esquemático do modelo}
\end{figure}
我提前致谢。致以最诚挚的问候。
答案1
正如我在上面的评论中提到的,并且 Zarko 也使用过,裁剪来自 clip 命令。这提出了一个问题,为什么首先有一个剪辑。我认为这很有可能与以下几行有关
\draw[dashed] (0,0) circle (4.2cm);
\filldraw[white] (-4.6, -4.6) rectangle (4.6,0);
\filldraw[white] (-4.6, 0) rectangle (0, 4.6);
画一个完整的圆,然后用白色覆盖四分之三。实现相同效果的更优雅的方法是只画一个圆弧
\draw[dashed] (4.2,0) arc (0:90:4.2);
而是。这导致了 MWE(其中我还删除了 vspace,正如 @daleif 所建议的,并由 @Zarko 使用,但未注明来源)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{patterns}
\begin{document}
\begin{figure}[h]
\centering
\label{fig:pendulum}
\begin{tikzpicture}[thick,>=latex,->]
% Trajectory projection
\draw[dashed] (4.2,0) arc (0:90:4.2);
% Bar
\draw[double distance=5mm, -] (3.15, 2.8) -- (0, 7);
\draw[double distance=5mm, -] (0,0) -- (3.2, 3.2);
% Motor
\draw[fill=white] (1.2,-1.0) -- (.5,0) arc(180:360:-0.5) -- (-1.2, -1.0) -- cycle;
\draw[draw=black,fill=white] (0, 0) circle circle (.15cm);
% Wheels
\draw (0.7, -1.2) circle (2mm);
\draw (-0.7, -1.2) circle (2mm);
% Base
\draw[pattern=north east lines] (-1.7, -1.6) rectangle (1.7, -1.4);
% Joints
\draw[draw=black,fill=white] (0, 0) circle circle (.15cm);
\draw[draw=black,fill=white] (3, 3) circle circle (.15cm);
\draw [dashed, -] (0, 0) -- (2, 2);
\draw [dashed, -] (0, 0) -- (0, 2);
\draw [dashed, -] (3, 3) -- (3, 5);
\draw [dashed, -] (3, 3) -- (0, 7);
% Axis
\draw[->] (2.6, 0) -- (3.6,0) node[below]{\texttt{x}};
\draw[->] (2.6, 0) -- (2.6, 1) node[above]{\texttt{y}};
% Angle
\draw[thick, -] (0.7, 0.7) arc (45:90:1);
\node at (.5, 1.5) {\Large $\theta_1$};
\draw[thick, -] (3, 3.7) arc (90:135:0.6);
\node at (2.7, 4.6) {\Large $\theta_2$};
\end{tikzpicture}
\caption{Desenho esquem\'atico do modelo}
\end{figure}
\end{document}
我通过添加以下内容仔细检查了边界框是否正确
\draw (current bounding box.south west) rectangle (current bounding
box.north east);