marinebon / infographiqR

R functions for creation of interactive intelligent infographics, ie infographiq
https://marinebon.github.io/infographiqR
MIT License
11 stars 2 forks source link

"take home message" on plot window? #28

Closed reikopm closed 6 years ago

reikopm commented 6 years ago

How would you feel about a brief text "take home message" that goes at the top of the infographic plot window?

I'm thinking about the non-science audience, i.e. decision makers. Instead of leaving it up to the viewer to interpret the graphs, we give them the message we want them to hear, the sound bite.

So, for instance, say that sea urchins are abundant, which may not be a good thing. Or that the graph indicates that the urchin population is falling, which may be a good thing. It could be confusing because urchins are destructive but they are also a commercial product. We could even point them to a link, such as http://sanctuarysimon.org/news/2017/07/urchins-continue-to-dominate-parts-of-monterey-bay/

7yl4r commented 6 years ago

This is implemented (but not really used yet), although the caption is currently placed at the bottom of all of the plots.

There is a tiny bit of documentation on this in the /info-demo readme and you can see it in action by clicking on the parrotfish on the info-demo site.

We need to improve the documentation on this feature, and we plan to use it more extensively on info-fk (https://github.com/marinebon/info-fk/issues/18)

reikopm commented 6 years ago

Yes, I was thinking about the plot captions but as it appears at the bottom of the plot window it doesn't inform the viewer first thing. And it would be great if we could tell the viewer what to look for before they begin studying the plots. Also if there are a number of plots the user might not even get to the bottom. I myself didn't notice my plot caption for phytoplankton.

I was wondering if there could be captions per plot. This would be a way to add more text to the plot window without overwhelming the viewer.

reikopm commented 6 years ago

Here's an example. I'd like to point out the importance of phytoplankton. Why decision makers need to care. Why they need to look at/monitor these graphs.

phytoplankton_caption

7yl4r commented 6 years ago

I have removed svg_elements.csv$modal_text and added svg_elements.csv$modal_before and svg_elements.csv$modal_after so that text can be included at the top or the bottom of a modal popup. I have also added the plot_caption column to plot_indicies.csv so that a caption may be included for each individual plot.

This new functionality is demonstrated in info-demo.

If you need more documentation on how to use these please let me know.

reikopm commented 6 years ago

I've made the modifications to svg_elements.csv and plot_indicators.csv but I keep running into this error: Error in if (!is.null(plot_caption) && !is.na(plot_caption)) { : missing value where TRUE/FALSE needed

The program runs the first element in svg_elements.csv and then crashes when processing the second element. I tried changing the order of the elements but it does not seem to make a difference.

Output: infographiq::create_info_site(site_title = "Monterey Bay Infographics", render_modals = T) [1] "\n\n ### INFOGRAPHIQ SITE GENERATOR ### \n\n" Parsed with column specification: cols( svg = col_character(), svg_id = col_character(), label = col_character(), status_text = col_character(), status_color = col_character(), modal_before = col_character(), modal_after = col_character() ) Parsed with column specification: cols( Classification_level = col_character(), svg_id = col_character(), plot_title = col_character(), filter = col_character(), col_t = col_character(), col_y = col_character(), col_se = col_character(), y_label = col_character(), group_by = col_character(), csv_url = col_character(), direct_path = col_character(), skip_lines = col_integer(), plot_caption = col_character() ) [1] "Brewing scene C:\Users\reiko\Documents\gitrepos\info-mb/rmd/kelp-forest.rmd" [1] "Brewing scene C:\Users\reiko\Documents\gitrepos\info-mb/rmd/pelagic.rmd" Parsed with column specification: cols( Classification_level = col_character(), svg_id = col_character(), plot_title = col_character(), filter = col_character(), col_t = col_character(), col_y = col_character(), col_se = col_character(), y_label = col_character(), group_by = col_character(), csv_url = col_character(), direct_path = col_character(), skip_lines = col_integer(), plot_caption = col_character() ) Parsed with column specification: cols( svg = col_character(), svg_id = col_character(), label = col_character(), status_text = col_character(), status_color = col_character(), modal_before = col_character(), modal_after = col_character() ) The following objects are masked from d_id_i (pos = 3):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 4):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 5):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 6):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 3):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 4):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 5):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 6):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 3):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 4):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 5):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 6):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

[1] "rendering modal C:\Users\reiko\Documents\gitrepos\info-mb/rmd/modals/pinnipeds.Rmd"

processing file: pinnipeds.Rmd |........ | 12% ordinary text without R code

|................ | 25% label: unnamed-chunk-1 (with options) List of 3 $ echo : logi FALSE $ message: symbol F $ warning: symbol F

|........................ | 38% ordinary text without R code

|................................ | 50% label: unnamed-chunk-2 Parsed with column specification: cols( time (UTC) = col_datetime(format = ""), mean_growth_rate (kg/day) = col_double() ) |......................................... | 62% ordinary text without R code

|................................................. | 75% label: unnamed-chunk-3 Parsed with column specification: cols( time (UTC) = col_datetime(format = ""), mean_weight (kg) = col_double() ) |......................................................... | 88% ordinary text without R code

|.................................................................| 100% label: unnamed-chunk-4 Parsed with column specification: cols( time (UTC) = col_datetime(format = ""), live_pup_count (count) = col_double() )

output file: pinnipeds.knit.md

"C:/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS pinnipeds.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pandoc4570506d19f1.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\reiko\Documents\R\win-library\3.4\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\reiko\AppData\Local\Temp\RtmpQreDqg\rmarkdown-str457062547705.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"

Output created: C:\Users\reiko\Documents\gitrepos\info-mb/rmd/modals/pinnipeds.html The following objects are masked from d_id_i (pos = 3):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 4):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 5):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 6):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

[1] "rendering modal C:\Users\reiko\Documents\gitrepos\info-mb/rmd/modals/krill.Rmd"

processing file: krill.Rmd |................ | 25% ordinary text without R code

|................................ | 50% label: unnamed-chunk-1 (with options) List of 3 $ echo : logi FALSE $ message: symbol F $ warning: symbol F

|................................................. | 75% ordinary text without R code

|.................................................................| 100% label: unnamed-chunk-2 Parsed with column specification: cols( time (UTC) = col_datetime(format = ""), species_group = col_character(), mean_cpue (ln(catch+1)) = col_double(), Seup = col_double(), Selo = col_double() )

output file: krill.knit.md

"C:/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS krill.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pandoc45701dcb3029.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\reiko\Documents\R\win-library\3.4\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\reiko\AppData\Local\Temp\RtmpQreDqg\rmarkdown-str457036966dd3.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"

Output created: C:\Users\reiko\Documents\gitrepos\info-mb/rmd/modals/krill.html The following objects are masked from d_id_i (pos = 3):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 4):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 5):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 6):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 3):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 4):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 5):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

The following objects are masked from d_id_i (pos = 6):

Classification_level, col_se, col_t, col_y, csv_url, direct_path, filter, group_by,
plot_caption, plot_title, skip_lines, svg_id, y_label

Error in if (!is.null(plot_caption) && !is.na(plot_caption)) { : missing value where TRUE/FALSE needed In addition: Warning message: In .Internal(islistfactor(x, recursive)) : closing unused connection 4 (C:\Users\reiko\Documents\gitrepos\info-mb/rmd/modals/krill.Rmd)

7yl4r commented 6 years ago

missing value where TRUE/FALSE needed

@mhepner90 and I spent an hour frustrated by this issue yesterday, but I thought we had it fixed. I will pull info-mb and take a look. Somehow !is.null(plot_caption) && !is.na(plot_caption) is evaluating to NA and I have no idea what value of plot_caption could make that happen.

7yl4r commented 6 years ago

Ah. This is likely because info-mb/plot_indicators has commas within a column. Ideally this would be fine since they are encapsulated by double-quotes, but I think that the read_csv function being used (this one?) does not do that.

A workaround for you may be to remove the commas, but we should address this later too by supporting enclosed/escaped commas or at least giving a better error message.

reikopm commented 6 years ago

re: commas in columns This url has been in plot_indicators.csv from the beginning and has worked previously. csv_url

http://oceanview.pfeg.noaa.gov/erddap/tabledap/cciea_MM_pup_count.csvp?time,live_pup_count

reikopm commented 6 years ago

I removed those commas but I am still getting an error. http://oceanview.pfeg.noaa.gov/erddap/tabledap/cciea_MM_pup_count.csvp?time%2Cmean_weight

7yl4r commented 6 years ago

I have attempted (again) to fix the bug in infographiq and was able to build info-mb after removing a few more commas (mostly from plot_title).

7yl4r commented 6 years ago

I think this is resolved, but please re-open if it's still giving you trouble, @reikopm .