Well, you didn't tell us anything about your data, but plot() has to create space to draw ncol(mydataSNc)^2 plots. Depending on your graphics device, if you have more than about 45 columns in mydataSNc, you will hit the limit - although the plots will be illegible well before that.
---------------------------------------------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352 > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Karly Harrod > Sent: Wednesday, June 27, 2012 12:10 PM > To: r-help@r-project.org > Subject: [R] Error: figure margins too large > > Hello, > > I am running cluster analysis, and am attempting to create a graph of > my clusters. I keep on getting an error that says that my figure > margins are too large. > > d <- file.choose() > d <- read.csv(d,header=TRUE) > > mydataS <- scale(d, center = TRUE, scale=TRUE) > > #Converts mydataS from a matrix to a data frame > mydataS2 <- as.data.frame(mydataS) > > #removes "coden" variable > myvars <- names(mydataS2) %in% c("coden") > mydataSNc <- mydataS2[!myvars] > > #Determine number of clusters > wss <- (nrow(mydataSNc)-1)*sum(apply(mydataSNc,2,var)) > for (i in 2:15) > wss[i] <- sum(kmeans(mydataSNc, centers=i)$withinss) > > plot(1:15, wss, type="b", xlab="Number of Clusters",ylab="Within groups > sum of squares") > > #perform Kmeans with 2 clusters > kmSNc2 <- kmeans(mydataSNc,2) > #print conponents of kmSNc2 > print(kmSNc2) > > #plot 2 clusters > plot(mydataSNc, col = kmSNc2$cluster) > #plot 2 centers > points(kmSNc2$centers,col = 1:2, pch = 8) > > After the above bolded code, I get this following error: > > > #plot 2 clusters > > plot(mydataSNc, col = kmSNc2$cluster) > Error in plot.new() : figure margins too large > > #plot 2 centers > > points(kmSNc2$centers,col = 1:2, pch = 8) > Error in plot.xy(xy.coords(x, y), type = type, ...) : > invalid graphics state > > > I am have just started using R, so I am most definitely a beginner. > Any help that could be offered would be greatly appreciated. > > Thanks, > > Karly Harrod > SULI Intern, Computational Research Division > khar...@lbl.gov > Lawrence Berkeley National Laboratory > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.