Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3600948
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:33:35+00:00 2026-05-18T20:33:35+00:00

I found this question about changing the size of a ggplot2 plot in Sweave.

  • 0

I found this question about changing the size of a ggplot2 plot in Sweave. I added the Sweaveopts{width=3, height=3} and it does shrink the size of the plot, but it doesn’t scale down the text. So in the end, all of the numbers on the axes overlap.

Is there a way to scale the entire ggplot2 plot in Sweave so that I don’t have to manually scale every component in the original ggplot2 call? It seems like something I should be able to do, but I can’t find it in the ggplot2 book or on the website. Thanks!

FWIW, here’s my call in Sweave:

\SweaveOpts{width=3, height=3}
\begin{figure}
\begin{center}
<<fig=TRUE>>=
print(plot.m)
@
\end{center}
\caption{stuff}
\label{fig:stuff}
\end{figure}

And the call that generates the ggplot2 plot:

plot.m <- ggplot(temp, aes(date, spread)) + geom_bar(stat="identity") + scale_x_date(major="years", minor="months")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:33:36+00:00Added an answer on May 18, 2026 at 8:33 pm

    It’s basically a Sweave FAQ. Google and you will find a gazillion hits.

    One approach is to just write the file to pdf (no scaling) and to then scale on the \includegraphics command. I just looked at a vignette I finished a couple of days ago where I wanted something approximately as wide as the page and I did:

    \begin{figure}[t!]
      \centering
    <<someLabel,fig=TRUE,width=8>>=
    ## some R code omitted
    print(dotplot(foo ~ bar | someFactor, group=someThing, 
                  data=someDF, layout=c(1,3),
                  xlab="some X label", ylab="",
                  key=simpleKey(text=c("A","B"), space="top")))
    @
      \caption{Some caption.}
      \label{fig:someLabel}
    \end{figure}
    

    some basically just one width dimension at the Sweave options level. I found that small values do not work well — so try something bigger as eg 6 or 7 inches.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this question about changing the size of a ggplot2 plot in Sweave.
I asked a question about different testing frameworks yesterday. This question can be found
I searched for this and found Maudite's question about text editors but they were
I found this question, but the question is about how to get an image
I have found this question about the special function or in scheme: Joe Hacker
Reading this question I found this as (note the quotation marks) code to solve
I found this question in an old question in your website so i thought
I found this question that is discussing what I would like to do, but
I found this question that was very useful in learning the basics of the
I found this question which is a great starting point towards creating embedded widgets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.