Data Structure

## [1] "can11.tsv" "can12.tsv" "can21.tsv" "can22.tsv"
date mining other total
2013-01-01 -2.850581 1.554630 1.187306
2013-02-01 1.817405 1.772702 1.776345
2013-03-01 2.894831 1.879273 1.961509
date mining other
2010-01-01 12.58940 1.276840
2010-04-01 33.89071 5.842328
2010-07-01 40.60906 6.814514
date vancouver toronto rest
2010-01-01 85.05708 78.44315 88.95637
2010-02-01 85.43009 78.75323 89.03557
2010-03-01 85.98395 78.69509 89.26357
date ontario other total
2010-01-01 7.163440 13.00803 9.857602
2010-04-01 8.132658 18.30270 13.314303
2010-07-01 10.480245 12.00953 11.249248

Static Chart 1

FAME Output

ggplot2 Output

ggplotly

Issues: R plotly currently does not draw the secondary y-axis defined using the sec.axis parameter. Also, modifications to axis title positions and legends are not reflected properly and multi-line titles overlap with the plotly mode bar

latticeExtra Double Y-Scales

Static Chart 2

FAME Output

lattice Output

  • x-axis subticks: https://github.com/Rapporter/pander/blob/master/R/graph.R and Sarkar, 2008, Lattice: Multivariate Data Visualization with R, Springer, pp.146f.
  • missing: right y-axis label, automatic left y-axis label position, quarterly minor ticks, legend inside plot area in doubleYScale using corner([0;1],[0;1]), flashes outside legend, legend line colors on left-hand side
  • todo: expand x-axis, increase relative font size axis tick labels, increase visibility of grid lines using panel.grid()

Dygraphs

Todo

  • fix JS: keep axis ticks when drawYAxis = FALSE, keep horizontal lines when drawGrid = FALSE using drawXGrid and drawYGrid from version 1.1.0 (current version 2.0.0)

Plotly

Plotly Static Image Export (SVG)

fig_path <- "assets/img"
file_name <- "plotly-multiple-y"
svg_file <- paste0(file_name, ".svg")
svg_tofile <- file.path(fig_path, svg_file)
unlink(svg_tofile)
## chrome options
eCaps <- list(
  chromeOptions =
    list(prefs = list(
      "profile.default_content_settings.popups" = 0L,
      "download.prompt_for_download" = FALSE,
      "download.default_directory" = file.path(getwd(), fig_path)
      )))

## create plot
suppressMessages(
  rD <- RSelenium::rsDriver(port = 4590L,
                            browser = "chrome",
                            geckover = NULL,
                            iedrver = NULL,
                            phantomver = NULL,
                            extraCapabilities = eCaps,
                            verbose = FALSE)
)

p$layout$height <- 480                  # match interactive plot height
export(p = p, file = svg_file, selenium = rD)
Sys.sleep(1)
rDstop <- rD[["server"]]$stop()
knitr::include_graphics(svg_tofile)

## convert to print formats
rsvg_pdf(svg_tofile, file.path(fig_path, paste0(file_name, ".pdf")))
rsvg_ps(svg_tofile, file.path(fig_path, paste0(file_name, ".eps")))

ggiraph

date industry value value_scaled indlabel
1 2013-01-01 mining -2.850581 -0.7126454 Mining, quarrying, oil and gas extraction –>
49 2013-01-01 other 1.554630 1.5546297 <– Other
97 2013-01-01 total 1.187306 1.1873061 <– All industries