RStudio Error in plot.new() : figure margins too large
Asked Answered
G

3

5

Using R Studio when trying to plot an xts object using chartSeries() the following error pop's up:

Error in plot.new() : figure margins too large

However when plotting it directly in R there is no problem with the margins size.

How can I correct the margins size for R Studio.

Note: the time series has more than 10,000 observations/entries

Thanks

Glasser answered 30/3, 2016 at 16:41 Comment(4)
Suspect its not really an R issue... Just increase the size of the plot panel in Rstudio or change the graphics device eg. astrostatistics.psu.edu/datasets/R/html/grDevices/html/…Picayune
Possible duplicate of Error in plot.new() : figure margins too large in RPicayune
Please provide a reproducible example to demonstrate what you are trying to plot. Because this also means a minimal example, I recommend you attempt to either (a) reduce your data set to find a good breaking point (for your own troubleshooting), or (b) try it with a short-code randomly-generated dataset.Lederhosen
Unsure if this is what happened to you, but I had my plot window too small in RStudio and enlarged it, error goes away.Depreciatory
A
11

write this three lines:

graphics.off() par("mar") par(mar=c(1,1,1,1))

Aspergillum answered 29/11, 2016 at 0:9 Comment(0)
O
5

This sometimes happens in RStudio. In order to solve it you can use any one of the following approach.

  1. May be your "Plots" pane is too small. Just zoom it and see.
  2. "Clear All Plots" in Plots pane and see.
  3. Run "graphics.off()" in the console and see.
Oneidaoneil answered 6/8, 2016 at 6:3 Comment(0)
O
0
####################
#                  #
#    Exercise 1    #
#                  #
####################
auto <- read.csv("D:/forecasting-tutorial/vehicle.csv")
plot(auto$sales,
     type = "n",
     ylim = c(0, 5000),
     ylab = "Sales, '000 units",
     xlab = "Period",
     main = "US light vehicle sales in 1976-2016")
lines(auto$sales)

#plot of chunk forecasting-part-4

####################
#                  #
#    Exercise 2    #
#                  #
####################
auto$trend <- seq(1:nrow(auto))
auto$income_lag <- c(NA, auto$income[1:nrow(auto)-1])
auto$unemp_lag <- c(NA, auto$unemp[1:nrow(auto)-1])
auto$rate_lag <- c(NA, auto$rate[1:nrow(auto)-1])

####################
#                  #
#    Exercise 3    #
#                  #
####################
regressions_result <- regsubsets(sales ~ ., data = auto)
plot(regressions_result, col = colorRampPalette(c("darkgreen", "grey"))(10))
plot(regressions_result, col = colorRampPalette(c("darkgreen", "grey"))(10))
Error in plot.new() : figure margins too large`enter code here`
Oto answered 6/10, 2017 at 3:31 Comment(2)
How to solve, Error in plot.new() : figure margins too largeenter code here,Oto
graphics.off() par("mar") par(mar=c(1,1,1,1)), still can not run the plot(regressions_result, col = colorRampPalette(c("darkgreen", "grey"))(10)), in my laptop par("mar") [1] 7.1 5.1 6.1 3.1Oto

© 2022 - 2024 — McMap. All rights reserved.