Hello All, I am running the following code in RStudio, and I keep on getting an error message that says: "Error in plot.new() : figure margins too large" Is there something that I am doing wrong? # Import Data nba <- read.csv("http://datasets.flowingdata.com/ppg2008.csv", sep=",") nba #Sort Data (sorting by Points, but could be sorting by any other variable) nba <- nba[order(nba$PTS),] #Prepare Data: makes rows by player name instead of Row Number row.names(nba) <- nba$Name #Prepare Data: don't need first column anymore, so we get rid of it nba <- nba[,2:20] #Prepe Data: change data from a data frame to a data matrix nba_matrix <- data.matrix(nba) #Create Heat Map nba_heatmap <- heatmap(nba_matrix, Rowv=NA, Colv=NA, col = cm.colors(256), scale="column", margins=c(5,10)) Karly Harrod LBNL Summer Intern kharrod@lbl.gov Lawrence Berkeley National Laboratory [[alternative HTML version deleted]]
Your code works okay in a plan R terminal. It may be an Rstudio problem or perhaps you already have a graphics device open and are trying to draw into it? John Kane Kingston ON Canada> -----Original Message----- > From: kharrod at lbl.gov > Sent: Fri, 6 Jul 2012 10:39:41 -0700 > To: r-help at r-project.org > Subject: [R] Error in plot.new() : figure margins too large > > Hello All, > > I am running the following code in RStudio, and I keep on getting an > error message that says: "Error in plot.new() : figure margins too > large" > Is there something that I am doing wrong? > > > # Import Data > nba <- read.csv("http://datasets.flowingdata.com/ppg2008.csv", sep=",") > nba > > #Sort Data (sorting by Points, but could be sorting by any other > variable) > nba <- nba[order(nba$PTS),] > > #Prepare Data: makes rows by player name instead of Row Number > row.names(nba) <- nba$Name > #Prepare Data: don't need first column anymore, so we get rid of it > nba <- nba[,2:20] > #Prepe Data: change data from a data frame to a data matrix > nba_matrix <- data.matrix(nba) > > #Create Heat Map > nba_heatmap <- heatmap(nba_matrix, Rowv=NA, Colv=NA, col > cm.colors(256), scale="column", margins=c(5,10)) > > > Karly Harrod > LBNL Summer Intern > kharrod at lbl.gov > Lawrence Berkeley National Laboratory > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.____________________________________________________________ FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
Dear Karly, I don't know if you've resolved your problem but I just came across the same thing in RStudio and I think I've found out what the problem is. The problem seems to occur when the plot viewing panel (by default in the bottom right) is very small. The plot function tries to create a plot within the physical space of the plot panel. If the plot panel is tiny, then the default margins of the plot may be larger than the graph/graphic itself. It is then you get the error. The simple solution is just to increase the size of the plot area in Rstudio and then try to run the code again. The plot should be created no problem. If you are still getting the issue despite doing this, let me know and I'll try and look a bit deeper into the problem! Sean -- View this message in context: http://r.789695.n4.nabble.com/Error-in-plot-new-figure-margins-too-large-tp4635651p4644364.html Sent from the R help mailing list archive at Nabble.com.