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

modifying location legends of isoplot #220

Closed
jrfrun opened this issue Apr 27, 2020 · 4 comments
Closed

modifying location legends of isoplot #220

jrfrun opened this issue Apr 27, 2020 · 4 comments

Comments

@jrfrun
Copy link

jrfrun commented Apr 27, 2020

is there a way to modify the location where the legends get place in the iso-plot? Right now they cover up the data points and would like to be able to place them in a more appropriate location

@ericward-noaa
Copy link
Collaborator

Yes - I recently added a 'return_obj' argument to the plot_data function. If you update installation via Github, and set return_obj=TRUE, it'll return a ggplot object that you can modify as you wish

@jrfrun
Copy link
Author

jrfrun commented Apr 30, 2020

Eric
I did what you mentioned (or what I interpreted you mentioned) but when I did that I got an error

Skipping install of 'MixSIAR' from a github remote, the SHA1 (d8cf9ad) has not changed since last install.
Use force = TRUE to force installation
Warning message:
1 components of ... were not used.

We detected these problematic arguments:

  • return_obj

@ericward-noaa
Copy link
Collaborator

Hmmm, I don't know what exactly is going on. I tested this last week with @atchin's help, and think we got it working. Here's the test script below -- basically the killer whale script example from the manual, with 2 ways to make the plot (with and without saving it as a ggplot object). @atchin ran into an issue where he needed to set plot_save_pdf = FALSE (defaults to TRUE).

Code:
devtools::install_github("brianstock/MixSIAR",
dependencies = TRUE,
build_vignettes = FALSE)

library(MixSIAR)
mixsiar.dir <- find.package("MixSIAR")
paste0(mixsiar.dir,"/example_scripts")

mix.filename <- system.file("extdata", "killerwhale_consumer.csv", package = "MixSIAR")

mix <- MixSIAR::load_mix_data(filename=mix.filename,
iso_names=c("d13C","d15N"),
factors=NULL,
fac_random=NULL,
fac_nested=NULL,
cont_effects=NULL)

Replace the system.file call with the path to your file

source.filename <- system.file("extdata", "killerwhale_sources.csv", package = "MixSIAR")

source <- load_source_data(filename=source.filename,
source_factors=NULL,
conc_dep=FALSE,
data_type="means",
mix)

Replace the system.file call with the path to your file

discr.filename <- system.file("extdata", "killerwhale_discrimination.csv", package = "MixSIAR")

discr <- load_discr_data(filename=discr.filename, mix)

make original plot

plot_data(filename="isospace_plot", plot_save_pdf=TRUE, plot_save_png=FALSE, mix,source,discr, return_obj=FALSE)

make new plot that returns ggplot object

g = plot_data(filename="isospace_plot", plot_save_pdf=TRUE, plot_save_png=FALSE, mix,source,discr, return_obj=TRUE)
g

@brianstock
Copy link
Owner

brianstock commented May 4, 2020

Thanks Eric! For an example of modifying g and saving the new plot, see #222.

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

3 participants