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

plotting generates identical figures with different filenames #32

Open
CeresBarros opened this issue Aug 8, 2023 · 8 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@CeresBarros
Copy link
Member

Plotting in Biomass_speciesParameters@dev-stable is currently occurring during the init event via:

    Plots(gg, usePlot = FALSE, fn = print, ggsaveArgs = list(width = 10, height = 7),
          filename = paste("Pairwise species fits ", gsub(":", "_", sim$._startClockTime)))

meaning that each time the init is run a new figure file is created, because sim$._startClockTime will differ.

I can see the interest of doing so during module development phase, but when using this module in combination with others and when event caching is off, this creates a lot of duplicated figure files.

Is there a reason why we shouldn't overwrite the same figure with an update version?

@CeresBarros CeresBarros added the enhancement New feature or request label Aug 8, 2023
@achubaty
Copy link
Contributor

achubaty commented Aug 8, 2023

I agree that it not generally desirable, so I'm happy to have the clock time removed from the file name.

@CeresBarros
Copy link
Member Author

I'd also add that "Pairwise species fits" is not entirely what the plots are showing (a comparison between LandR growth curves and growth curves from fitted non-linear models) -- and spaces in file names aren't great either.
Could we also change the figure file names?

@achubaty
Copy link
Contributor

achubaty commented Aug 9, 2023

Yes, file names should be descriptive. Can you also ensure file names are prefixed by the module name? It makes it easier to associate specific figures with certain modules (and to find them as a human).

@CeresBarros
Copy link
Member Author

Can you also ensure file names are prefixed by the module name?

I partially agree with this. One the one hand, yes, appending the module name would facilitate finding figures and even interpreting them. However,

  1. it feels strange to me to do this for one module only
  2. If we propagate across modules that will mean changing many figure names
  3. in some cases, we may end up with very long filenames.

I wonder if, instead, we could (in this and and other modules in which to do this) create a module parameter that governs where figures are saved (e.g. P(sim)$.plotsPath). By default, Plots saves to a file.path(outputPath(sim), "figures") folder. This could still be the default P(sim)$.plotsPath, but the user could change that to file.path(outputPath(sim), "figures", "<moduleName>").

This partly addresses my point no. 1, in that the figure names would remain the same. It doesn't address no 2, as it still means changing internal code of several modules (and creating a new parameter), if we want to propagate this across modules. It fully addresses no 3, as filenames would remain as short/long as they currently are

@achubaty
Copy link
Contributor

achubaty commented Aug 9, 2023

I think separate subdirs for each module makes more sense. That could be an easy addition to SpaDES.core - provide an accessor to the module's figure dir so it doesn't need to specified manually, and it should be easy enough to propagate this change through each module.

@CeresBarros
Copy link
Member Author

In that case I'll hold off creating any parameters for Biomass_speciesParameters or changing the filename above, other than removing clocktime

@CeresBarros
Copy link
Member Author

Actually, scratch that. I'll still suggest/PR a more accurate filename wrt what the figure is about.

@achubaty
Copy link
Contributor

achubaty commented Aug 9, 2023

I implemented figurePath() for simList objects (PredictiveEcology/SpaDES.core#249), which becomes the default mechanism used by Plots() when writing files.

When called from a module, figurePath(sim) will return the value of file.path(outputPath(sim), "figures", moduleName). When not called from a module, it simply drops the moduleName component.

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

No branches or pull requests

4 participants