0

I have the following R code to generate a tikzdevice plot:

tikz(file = "plot_CIs.tex", width = 5, height = 5)
par(cex = 0.8)
ggplot(confidence_interval, aes(x = Statistic, y = Values, group = 1)) +
  geom_errorbar(width = 0.1, aes(ymin = Lower_Bound, ymax = Upper_Bound)) +
  geom_point(shape = 21, size = 3, fill = "white") +
  labs(title = title, subtitle = subtitle) +
  theme(plot.title = element_text(hjust = 0.5)) +
  theme(plot.subtitle = element_text(hjust = 0.5))

In latex I then use the following:

\documentclass{article}
%The package tikz is available in pgf
\usepackage{tikz}
\usepackage[justification=centering]{caption}

\begin{document}

\begin{figure}
  %Do not try to scale figure in .tex or you loose font size consistency
      \centering
  %The code to input the plot is extremely simple
  \input{../plot_CIs.tex}
  %Captions and Labels can be used since this is a figure environment
  \caption{Sample output from tikzDevice}
  \label{plot:test}
\end{figure}
\end{document}

Which results in this image (in a latex pdf): tikzout

I receive the following warning when compiling the latex document:

Overfull \hbox (16.35pt too wide)

which according the the log is related to:

(../plot_CIs.tex)
Overfull \hbox (16.35pt too wide) in paragraph at lines 12--14

How do I fix this warning? If I were using \includegraphics for my image, I would simply do:

includegraphics[width=\linewidth]{plot_CIs.tx}

Is there a way to do the same using \input for tikzdevice plots?

Thanks!

1

You could use \resizebox like this:

\resizebox{\linewidth}{!}{\input{../plot_CIs.tex}}

Untested since you do not provide a minimal and complete example.

Alternatively you could adjust the width argument in the tikz(...) call.

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.