2

I have a figure created on the TikZ and it got cropped by the outer box. Is it possible to resize it such that the whole figure is displayed? The image and code are on the URLs below.

Image: https://imgur.com/Pe9LqTb

Code: [Edited]

\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}

I thank in advance. Best regards.

  • 1
    You'll get more people willing to help if you provide the full code for a MWE. Otherwise, you force people to spend extra time figuring out what you used, such as \usetikzlibrary{patterns}, to get your code to work. – DJP Nov 7 '18 at 19:25
  • 1
    The cropping comes from the \clip command in the beginning. Try adjusting its path (if you do not feel like providing a complete compilable code). – user121799 Nov 7 '18 at 19:29
  • What is that vs pace doing there? – daleif Nov 7 '18 at 19:39
0

As I mentioned in my above comment, and as has also been used by Zarko, the cropping comes from the clip command. This raises the question why there is a clip in the first place. I think that there is a great chance that it is related to the lines

    \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);

which draw a full circle but then overpaint three quarters of it in white. An arguably more elegant way to achieve the same is to just draw an arc

        \draw[dashed] (4.2,0) arc (0:90:4.2);

instead. This leads to the MWE (in which I also dropped vspace, as suggested by @daleif and used by @Zarko without acknowledgment)

\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}

enter image description here

I double-checked that the bounding box is as it should be by adding

    \draw (current bounding box.south west) rectangle (current bounding
    box.north east);

enter image description here

  • I thank you sincerely for the answer. Thank you for the help. – Bruno Henrique Peixoto Nov 7 '18 at 23:22
0
  • your code snippet has erros
  • it is not clear why you use \vspace{10in} inside picture. it hasn9t any influence on image
  • removing errors and correct size of \clip i obtain the following result:

enter image description here

note: with this the fonts will not be scaled

if picture is for some reason too big, you can add option scale to tikzpicture:

\begin{tikzpicture}[scale=0.8, .... ]

how this picture fit into your document, i don't know. to see this you need to provide an example of document with layout of your real document.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.