By hrbrmstr
It’s been a while since I’ve updated my metricsgraphics package. The hit list for changes includes:
- Fixes for the new ggplot2 release (metricsgraphics uses the
movies
data set which is now in ggplot2movies) - Updated all javascript libraries to the most recent versions
- Borrowed the ability to add CSS rules to a widget from taucharts (
mjs_add_css_rule
) - Added a metricsgraphics plugin to enable line chart region annotation (
mjs_annotate_region
) - Enabled explicit coloring line/area charts (it was a new feature in the underlying Metrics-Graphics library)
- You can use bare or quoted names when specifying the x & y accessors and can also use a variable name
- You can now use the metricsgraphics title & description capabilities, but doing so voids any predictable/specified widget height/width and the description functionality is really only suited for bootstrap templates
I think all that can be demonstrated in the following snippet:
library(metricsgraphics) dat read.csv("http://real-chart.finance.yahoo.com/table.csv?s=AAPL&a=07&b=9&c=1996&d=11&e=21&f=2015&g=d&ignore=.csv", stringsAsFactors=FALSE) DATE "Date" dat %>% filter(Date>="2008-01-01") %>% mjs_plot(DATE, y="Low", title="AAPL Stock (2008-Present)", width=800, height=500) %>% mjs_line(color="#6a3d9a") %>% mjs_add_line(High, color="#ff7f00") %>% mjs_axis_x(xax_format="date") %>% mjs_add_css_rule("{{ID}} .blk { fill:black }") %>% mjs_annotate_region("2013-01-01", "2013-12-31", "Volatility", "blk") %>% mjs_add_marker("2014-06-09", "Split") %>% mjs_add_marker("2012-09-12", "iPhone 5") %>% mjs_add_legend(c("Low", "High")) |
NOTE: I’m still trying to figure out why WebKit on Safari renders the em dashes and Chrome does not.
Related
To leave a comment for the author, please follow the link and comment on their blog: R – rud.is.
R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more…
If …read more
Source:: r-bloggers.com