Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in plot_prior #356

Open
Coastal-Keith opened this issue Sep 1, 2023 · 9 comments
Open

Error in plot_prior #356

Coastal-Keith opened this issue Sep 1, 2023 · 9 comments

Comments

@Coastal-Keith
Copy link

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

@DSchimmenti
Copy link

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

@brianstock
Copy link
Owner

brianstock commented Oct 18, 2023 via email

@Coastal-Keith
Copy link
Author

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
Copy link
Author

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
Copy link
Author

Coastal-Keith commented Oct 25, 2023

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

@DSchimmenti
Copy link

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
Copy link

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?

@Coastal-Keith
Copy link
Author

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.

@shwalters
Copy link

shwalters commented Aug 14, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants