68201

Histogram, error: Error in plot.new() : figure margins too large [duplicate]

<div class="question-status question-originals-of-duplicate">

This question already has an answer here:

    <li> Error in plot.new() : figure margins too large in R <span class="question-originals-answer-count"> 11 answers </span> </li> </ul>

    I have to plot 141 histograms in R. I am working with windows 8. then I write:

    par(mfcol=c(12,12), oma=c(1,1,0,0)) for(m in 1:141 ){ x <- precData[[m]] hist(x[x != 0],30, xlab=NA, ylab=NA, main=statData$Name[m]) }

    But always I get this error: Error in plot.new() : figure margins too large

    How can I solve it?? Is there any command for adjusting the size of each histogram??

    Thanks.

    Answer1:

    You set the outer margins (outside the whole set of plots) but the inner margins (for each panel) are at the default. With the margins at the default, there is not enough room within each panel to plot the histogram and have the marginal information.

    So you need to change the inner margins as well, and if you want anything to look reasonable then you should also change size and position of the things to be added.

    Here is an example (I had to change to random data since your example was not reproducible):

    par(mfcol=c(12,12), oma=c(1,1,0,0), mar=c(1,1,1,0), tcl=-0.1, mgp=c(0,0,0)) for(m in 1:141 ){ x <- rnorm(100) hist(x[x != 0],30, xlab=NA, ylab=NA, main=paste('data: ',m), cex.axis=0.5, font.main=1, cex.main=0.8) }

    Answer2:

    If it occurs using RStudio, you could try to enlarge your plot window. Sometimes it helps.

Recommend

  • Sharing a Legend between two combined ggplots
  • Displaying *(star) superscript in R - expression( )
  • R X-axis Date Labels using plot()
  • ggplot not adding legend. What am I missing? very new to R
  • ggplot2 - How to add labels to multiple plots figure?
  • Print ggplot y axis values in 10 thousands
  • Setting the color label and varying the color palette in qplot
  • Use of Pragmas in Ada
  • Getting started with Pylint for Jython (jython2.5.1)
  • Plotting a histogram from cellvalues
  • Put percent labels next to legend instead of in the slice
  • pandas computation in each group
  • Xaml, wpf image position and crop issue
  • Inversing an interpolation of rotation
  • Put value at centre of bins for histogram
  • C# - Most efficient way to iterate through multiple arrays/list
  • HttpClient: disabling chunked encoding
  • How to estimate the Kalman Filter with 'KFAS' R package, with an AR(1) transition equation
  • Display validation errors inside
  • Floated image with variable width and heading with background image
  • Plotting line graph with factors in R
  • Extract zip entries to another Zip file
  • Using a canvas object in a thread to do simple animations - Java
  • GridView breaks while scrolling
  • How to change the font size of a single index for UISegmentedControl?
  • Time complexity of a program which involves multiple variables
  • Atlas images wrong size on iPad iOS 9
  • Change multiple background-images with jQuery
  • Android screen density dpi vs ppi
  • output of program is not same as passed argument
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Change an a tag attribute in JavaScript based on screen width
  • Akka Routing: Reply's send to router ends up as dead letters
  • unknown Exception android
  • Checking variable from a different class in C#
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app
  • java string with new operator and a literal