MixSIAR icon indicating copy to clipboard operation
MixSIAR copied to clipboard

Error in plot_prior

Open Coastal-Keith opened this issue 1 year ago • 9 comments

Analyzing 2 isotope tracers in a source contribution study.

When I run code to run the mixSIAR model, I get an error code for the code block "plot_prior(alpha.prior = 1, source)". Error reads "Error in plot.new() : figure margins too large". The model will continue & successfully run, but no files are saved to my working directory with no evidence that I ran the model.

Things I've done to try to fix the error.

  • Reduced figure margin sizes using "par(mar = c(1,1,1,1))"

  • Increase plot window size.

  • Save figures as PDF.

R.version 4.2.2 Windows 10, 64-bit

Coastal-Keith avatar Sep 01 '23 20:09 Coastal-Keith

I am having the same issue using R version 4.3.1 in RStudio version 2023.09.0+463 on Mac OS 14

DSchimmenti avatar Oct 17 '23 17:10 DSchimmenti

RStudio can have problems with graphics. Have you tried running outside RStudio?

On Tue, Oct 17, 2023, 7:27 PM DSchimmenti @.***> wrote:

I am having the same issue using R version 4.3.1 in RStudio version 2023.09.0+463 on Mac OS 14

— Reply to this email directly, view it on GitHub https://github.com/brianstock/MixSIAR/issues/356#issuecomment-1766859665, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHDA46RJYFO4KD74HFJFM3X725XFAVCNFSM6AAAAAA4IANQ4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRWHA2TSNRWGU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

brianstock avatar Oct 18 '23 08:10 brianstock

I am having the same issue using R version 4.3.1 in RStudio version 2023.09.0+463 on Mac OS 14

Have you got it to work? Turning the dev.off, uninstalling and reinstalling did not help either. Also ran code in an RMD file & it did not work either.

Coastal-Keith avatar Oct 25 '23 18:10 Coastal-Keith

RStudio can have problems with graphics. Have you tried running outside RStudio? On Tue, Oct 17, 2023, 7:27 PM DSchimmenti @.> wrote: I am having the same issue using R version 4.3.1 in RStudio version 2023.09.0+463 on Mac OS 14 — Reply to this email directly, view it on GitHub <#356 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHDA46RJYFO4KD74HFJFM3X725XFAVCNFSM6AAAAAA4IANQ4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRWHA2TSNRWGU . You are receiving this because you are subscribed to this thread.Message ID: @.>

I have not yet. Will be trying Visual Studio or maybe anaconda. Was told to try R's native GUI as well.

Coastal-Keith avatar Oct 25 '23 18:10 Coastal-Keith

RStudio can have problems with graphics. Have you tried running outside RStudio? On Tue, Oct 17, 2023, 7:27 PM DSchimmenti @.> wrote: I am having the same issue using R version 4.3.1 in RStudio version 2023.09.0+463 on Mac OS 14 — Reply to this email directly, view it on GitHub <#356 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHDA46RJYFO4KD74HFJFM3X725XFAVCNFSM6AAAAAA4IANQ4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRWHA2TSNRWGU . You are receiving this because you are subscribed to this thread.Message ID: @.>

R's GUI is throwing the same error as Rstudio was.

image

Coastal-Keith avatar Oct 25 '23 18:10 Coastal-Keith

RStudio can have problems with graphics. Have you tried running outside RStudio? On Tue, Oct 17, 2023, 7:27 PM DSchimmenti @.> wrote: I am having the same issue using R version 4.3.1 in RStudio version 2023.09.0+463 on Mac OS 14 — Reply to this email directly, view it on GitHub <#356 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHDA46RJYFO4KD74HFJFM3X725XFAVCNFSM6AAAAAA4IANQ4OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRWHA2TSNRWGU . You are receiving this because you are subscribed to this thread.Message ID: @.>

I've tried running outside of RStudio in base R and I'm running into the same issue. I still get the "Error in plot.new() : figure margins too large" error message similar to @Coastal-Keith above

DSchimmenti avatar Oct 30 '23 17:10 DSchimmenti

I have attempted plotting the priors for a different set of data with 5 sources, and R produced the plot without giving me that error message. The dataset I am running into the error with has 11 sources, so I wonder if that is the issue- when you have larger numbers of sources?

DSchimmenti avatar Oct 30 '23 17:10 DSchimmenti

I have attempted plotting the priors for a different set of data with 5 sources, and R produced the plot without giving me that error message. The dataset I am running into the error with has 11 sources, so I wonder if that is the issue- when you have larger numbers of sources?

I still haven't gotten it work. Have you gotten yours to work with all 11 sources? I also have a larger number of sources.

Coastal-Keith avatar Nov 21 '23 21:11 Coastal-Keith

Hello mixing friends,

I was running into the same problem and just got it to work. The number of sources before combining can just be too many to fit on the screen displaying the graphics device created by the combine_sources function.

So, I copied and pasted the function code from here on GitHub into a new R script file, and changed line 197 from dev.new() to now be pdf("file_name.pdf", width = 10, height = 20).

#' dev.new(width=9, height=7) #Could probably change the size here instead, but not likely be able to see it all pdf("file_name.pdf", width = 10, height = 20) #Whatever height is large enough to work for your data

You'll want to rename the function so it doesn't conflict, and use the source function to call it into your environment. I changed the function name to combine_sources2, and named the R file the same. In my analysis script I ran the following:

source("combine_sources2.R") combined <- combine_sources2(jags_model, mix, source, alpha.prior=1, groups=list(...))

Now I get a PDF file of the prior plot without it stopping the whole process due to plot size.

I hope this helps for anyone still struggling with this!

shwalters avatar Aug 14 '24 15:08 shwalters