Daniel
Daniel

Reputation: 51

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

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

Upvotes: 5

Views: 38005

Answers (3)

bambangpe
bambangpe

Reputation: 1

####################
#                  #
#    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`

Upvotes: 0

Hiren
Hiren

Reputation: 1435

write this three lines:

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

Upvotes: 11

Mahan
Mahan

Reputation: 441

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.

Upvotes: 5

Related Questions