OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How do I avoid title and axis labels being cut off in PDF?

  • Thread starter Thread starter hawkaterrier
  • Start date Start date
H

hawkaterrier

Guest
I'm having some difficulty getting the PDF version of my plot to show the title and axis labels. They show up fine in the RStudio plot window, but get cut off in the PDF. I've tried a few things, including different margin settings, the pdf() function with dev.off() but keep getting the same result no matter what I try. Any ideas where I'm going wrong?

Code:
library(ggplot2)

#Plot
par(mar=c(6, 6, 6, 2))
ggplot(data = paymentsNY, aes(x = Average.Covered.Charges/1000, y = 
Average.Total.Payments/1000, alpha = 0.25))+ 
geom_point()+
xlab("Mean covered charges ($'000s)")+
ylab("Mean total payments ($'000s)")+
ggtitle("Mean covered charges and mean total payments - NY")+
theme(title = element_text((size = 16)))+
theme(legend.position = "none")+
geom_smooth(method = "lm")

#Write plot as PDF
ggsave("payments_NY.pdf")

Thanks
<p>I'm having some difficulty getting the PDF version of my plot to show the title and axis labels. They show up fine in the RStudio plot window, but get cut off in the PDF. I've tried a few things, including different margin settings, the pdf() function with dev.off() but keep getting the same result no matter what I try. Any ideas where I'm going wrong?</p>

<pre><code>library(ggplot2)

#Plot
par(mar=c(6, 6, 6, 2))
ggplot(data = paymentsNY, aes(x = Average.Covered.Charges/1000, y =
Average.Total.Payments/1000, alpha = 0.25))+
geom_point()+
xlab("Mean covered charges ($'000s)")+
ylab("Mean total payments ($'000s)")+
ggtitle("Mean covered charges and mean total payments - NY")+
theme(title = element_text((size = 16)))+
theme(legend.position = "none")+
geom_smooth(method = "lm")

#Write plot as PDF
ggsave("payments_NY.pdf")
</code></pre>

<p>Thanks</p>
Continue reading...
 

Latest posts

Top