Code Monkey home page Code Monkey logo

gadgetplots's Introduction

gadgetplots

Plot gadget3 model output using ggplot2. R package version 0.3.0

The gadgetplots package produces diagnostics graphics for gadget3 using ggplot2. The package replaces the plotting capabilities of Rgadget package which was designed to work with gadget2.

Installation

The gadgetplots is not available on CRAN yet. Use the devtools or remotes packages to install directly from GitHub:

# install.packages("remotes")
remotes::install_github("gadget-framework/gadgetplots")

Usage

See the function reference for a detailed list of functions and documentation on how to use them.

The make_html() function generates a single html file out of gadgetutils::g3_fit() output that contains key model diagnostics. Further, the package produces plots in four categories:

  1. plot_*() functions plot gadget model output generated using gadgetutils::g3_fit(). These functions have a generic shorthand, the plot(), with param argument specifying the type of plot.

  2. dplot_*() functions plot gadget model input data generated using mfdb, gadgetutils::g3_data() or gadgetutils::add_g3_attributes() functions.

  3. the g3d_plot() function plots data directly from a gadget model object.

  4. g3plot_* functions plot gadget suitability (selectivity) functions.

Found a bug or desire a feature?

The package is under an active development together with gadget3 framework. Please report bugs and write feature requests under Issues.

gadgetplots's People

Contributors

mikkovihtakari avatar willbutler42 avatar bthe avatar

Watchers

Jamie Lentin avatar  avatar Valerio Bartolino avatar Margarita avatar Kostas Georgiou avatar  avatar

gadgetplots's Issues

Input data plots

I think it would be nice to have a possibility to plot input data to see how they look before passing them into a gadget model. I have some functions in my ghl model project which I could add. Now the question is how to name them to separate them from model output figures?

Output figures are currently named as plot_*. Would dplot_ (data plot) work? Should output figures then be renamed mplot_* or should we keep them as they are for consistency with the rgadget package?

Plot model

Hi,

I thought it would be nice to be able to automatically plot a gadget model. Thought of basing this on g3_fit object. This is as far as I got for now. Posting it here in case someone gets inspired to continue. If not, I'll continue next year.

library(dplyr)
library(DiagrammeR)

stocks <- fit$res.by.year %>%
  filter(year == max(year)) %>%
  mutate(size = total.biomass/sum(total.biomass),
         type = "stock") %>%
  rename("name" = "stock") %>%
  dplyr::select(name, type, size)

fleets <- fit$fleet.info %>%
  filter(year == max(year)) %>%
  mutate(size = amount/sum(amount),
         type = "fleet") %>%
  rename("name" = "fleet") %>%
  dplyr::select(name, type, size)

predation <- optim_fit$suitability %>%
  dplyr::ungroup() %>%
  dplyr::filter(suit > 0) %>%
  dplyr::select(stock, fleet) %>%
  dplyr::distinct()

graph <- create_graph()

## ####

graph %>%
  add_nodes_from_table(
    table = bind_rows(stocks, fleets) %>% rename("value" = "size"),
    label_col = name,
    type_col = type
  ) %>%
  add_edges_from_table(
    table = predation,
    from_col = stock,
    to_col = fleet,
    from_to_map = label
  ) %>%
  set_node_attrs(
    node_attr = 'fontcolor',
    values = 'black'
  ) %>%
  select_nodes(type == "stock") %>%

  set_node_attrs_ws(
    node_attr = fillcolor,
    value = "orange") %>%
  set_node_attrs_ws(
    node_attr = shape,
    value = "rectangle") %>%
  set_node_attrs_ws(
    node_attr = y,
    value = 4) %>%
  clear_selection() %>%
  render_graph("tree")

Iceland template

A list of suggestions for an 'Iceland' template (f98aa81):

  1. Annual plots - F instead of HR
  2. Maturity observations as points

row limit for multi-panelled plots?

If there is lots of data, it can be hard to discern how well the model fits ldists and age-length data. Need to have a think how visualising this can be improved, maybe having a row limit per page (creating multiple pages if the limit is exceeded) or something along these lines would work

plots to compare fits

We should develop some plotting tools to facilitate model comparisons. A good starting point would be allowing each panel of the annual plots to include multiple fits. plot_biomass and plot_rec can do this using facet_wrap so just need to extend this capability to single panels. Would be handy for SIs too

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.