-
Notifications
You must be signed in to change notification settings - Fork 2
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
support multiple plot types? #21
Comments
will need to modify modal_plot template |
after further discussion with Ben, I believe we do want to expand support for multiple different ways of generating plots and we feel that the best way is to embed R code directly in the csv column. Default behavior will be to use plot_timeseries, so new users can leave the plot_function_call column empty, advanced users can use this column to override the plot_timeseries call. |
That would work great for me. Jen Brown (MBNMS) wanted a taxonomic structure plot which I implemented in R using a bar graph on seasonal averages over 16 taxonomic groups. This is what the code looks like: urlstr='https://raw.githubusercontent.com/reikopm/info-mb/master/prep/data/phytoplankton/efm_taxa_structure_means.csv' library(plotly) t <- list( p1 <- plot_ly(dat, x = ~Season, y = ~asyn, type = 'bar', name = 'Synechococcus',width=2040, height=1080) %>% |
This looks great @reikopm ! I'll try to work this into the framework as a slightly more generic function. Along with seascape plot and multiple time series (eg in/out MPAs) a la: Side note:
|
It looks like we need this functionality to show the seascapes streamgraphs as well. @bbest : do you have a specific plan for this or would you like me to take a swing at it? |
Hey @reikopm, Sorry, been focused on the Explorer app. Am discussing this now with @7yl4r and we're considering putting whole functions in the csv, which could then be evaluated. For instance: txt = "urlstr='https://raw.githubusercontent.com/reikopm/info-mb/master/prep/data/phytoplankton/efm_taxa_structure_means.csv'
dat <- read.csv(url(urlstr))
library(plotly)
t <- list(
family = 'helvetica',
size = 24,
color = 'black')
p1 <- plot_ly(dat, x = ~Season, y = ~asyn, type = 'bar', name = 'Synechococcus',width=2040, height=1080) %>%
add_trace(y = ~arfp, name = 'Red Fluorescing Picoplankton') %>%
add_trace(y = ~aprym, name = 'Haptophyte') %>%
add_trace(y = ~aaflag, name = 'Autotrophic Flagellate') %>%
add_trace(y = ~aadino, name = 'Autotrophic Dinoflagellate') %>%
add_trace(y = ~acryp, name = 'Cryptomonad') %>%
add_trace(y = ~aprasy, name = 'Prasinophyte') %>%
add_trace(y = ~aphaeo, name = 'Phaeocystsis') %>%
add_trace(y = ~apen, name = 'Pennate Diatom') %>%
add_trace(y = ~acen, name = 'Centric Diatom') %>%
add_trace(y = ~ahdino, name = 'Heterotrophic Dinoflagellate') %>%
add_trace(y = ~ahflag, name = 'Heterotrophic Flagellate') %>%
add_trace(y = ~achoano, name = 'Choanoflagellate') %>%
add_trace(y = ~ahcryp, name = 'Leucocryptos') %>%
add_trace(y = ~ahcil, name = 'Heterotrophic Ciliate') %>%
add_trace(y = ~aacil, name = 'Autotrophic Ciliate') %>%
layout(font=t,yaxis = list(title = 'mg C m-3'),barmode = 'stack') %>%
layout(font=t,title = 'Q10:Taxonomic Structure', margin = 1)
print(p1)"
eval(parse(text=txt)) Similarly you could include static images that have a URL like so: txt = "knitr::include_graphics('./fish_diversity.png')"
eval(parse(text=txt)) Or leaflet marker cluster: txt = "library(tidyverse)
library(leaflet)
leaflet(quakes) %>%
addTiles() %>%
addMarkers(
clusterOptions = markerClusterOptions())"
eval(parse(text=txt)) I am admittedly nervous about any major architectural changes like this though before we do live demos. @7yl4r is going to play with this in a sandbox (ie github branch) to not affect anything else. |
planned options for new column
|
I have implemented 1, 2.i, 2.ii, 2.v, and 3 above; opened new issues for 2.iii (#36) and 2.iv (#35) since they are a bit bigger. Initially I kept these commits on the multiplots branch, but I tested building info-demo, info-fk, and info-mb and ran into no issues so I have merged the changes into master. For now the best place to look to figure out how to use all this functionality is at the marinebon/info-demo readme - specifically the lobster section. |
include
plotting_function_call
column inindicators.csv
:plot_series(title="my title")
raw_html_passthrough or img_wrapper could be functions that could be called too.
The text was updated successfully, but these errors were encountered: