Package rtsplot. September 15, 2018

Similar documents
Package desplot. R topics documented: April 3, 2018

Package rtsdata. October 26, 2018

Package areaplot. October 18, 2017

Package docxtools. July 6, 2018

Package ggimage. R topics documented: December 5, Title Use Image in 'ggplot2' Version 0.1.0

Package basictrendline

Package pairsd3. R topics documented: August 29, Title D3 Scatterplot Matrices Version 0.1.0

Package sankey. R topics documented: October 22, 2017

Package Mondrian. R topics documented: March 4, Type Package

Package ggimage. R topics documented: November 1, Title Use Image in 'ggplot2' Version 0.0.7

Desktop Studio: Charts. Version: 7.3

Package ConvergenceClubs

Package spark. July 21, 2017

Desktop Studio: Charts

Package Rspc. July 30, 2018

You can retrieve the chart by inputting the symbol of stock, warrant, index futures, sectoral

Package CorporaCoCo. R topics documented: November 23, 2017

Package harrypotter. September 3, 2018

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package memery. February 13, 2018

Package weco. May 4, 2018

Package replicatedpp2w

Package repec. August 31, 2018

Package naivebayes. R topics documented: January 3, Type Package. Title High Performance Implementation of the Naive Bayes Algorithm

Package apastyle. March 29, 2017

Package ClustGeo. R topics documented: July 14, Type Package

Error-Bar Charts from Summary Data

Package ECctmc. May 1, 2018

Package superheat. February 4, 2017

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package projector. February 27, 2018

Package panelview. April 24, 2018

Package darksky. September 20, 2017

Package multigraph. R topics documented: November 1, 2017

Package EnQuireR. R topics documented: February 19, Type Package Title A package dedicated to questionnaires Version 0.

Package nima. May 23, 2018

Package crochet. January 8, 2018

Package meme. November 2, 2017

Package d3heatmap. February 1, 2018

Package gridgraphics

Package gtrendsr. August 4, 2018

Package pathdiagram. R topics documented: August 29, 2016

Package arphit. March 28, 2019

Technology Assignment: Scatter Plots

Package customlayout

Package ExceedanceTools

Package beanplot. R topics documented: February 19, Type Package

Package icesadvice. December 7, 2018

Package JBTools. R topics documented: June 2, 2015

Statistical Programming with R

Using Built-in Plotting Functions

Package nprotreg. October 14, 2018

Package rafalib. R topics documented: August 29, Version 1.0.0

Package rtext. January 23, 2019

Package meme. December 6, 2017

Package nngeo. September 29, 2018

Package visualize. April 28, 2017

Package rplotengine. R topics documented: August 8, 2018

Package waterfall. R topics documented: February 15, Type Package. Version Date Title Waterfall Charts in R

Graphics - Part III: Basic Graphics Continued

Package blandr. July 29, 2017

Package Daim. February 15, 2013

Package messaging. May 27, 2018

Package omu. August 2, 2018

Package MmgraphR. R topics documented: September 14, Type Package

Package bigreadr. R topics documented: August 13, Version Date Title Read Large Text Files

Package multigraph. R topics documented: January 24, 2017

Package kofnga. November 24, 2015

Package readmzxmldata

Chapter 10 Working with Graphs and Charts

Bar Charts and Frequency Distributions

Package scatterd3. March 10, 2018

Package revealjs. R topics documented: March 13, Type Package

Package fso. February 19, 2015

Package sspline. R topics documented: February 20, 2015

Package Rwinsteps. February 19, 2015

Package abf2. March 4, 2015

1 Introducing Charts in Excel Customizing Charts. 3 Creating Charts That Show Trends. 4 Creating Charts That Show Differences

Package TVsMiss. April 5, 2018

Lesson 4 Customize the ToolBox

Package gridextra. September 9, 2017

Package d3plus. September 25, 2017

Package smoothr. April 4, 2018

Plotting: An Iterative Process

Package osrm. November 13, 2017

Package lvplot. August 29, 2016

Package profvis. R topics documented:

Package gameofthrones

R topics documented: 2 clone

Package sizemat. October 19, 2018

Package sciplot. February 15, 2013

Package SFtools. June 28, 2017

Create Web Charts. With jqplot. Apress. Fabio Nelli

Package CausalImpact

Package balance. October 12, 2018

Package curvhdr. April 16, 2017

Package rvg. February 13, 2018

Package ggrepel. September 30, 2017

Package farver. November 20, 2018

Package qicharts. October 7, 2014

Transcription:

Tpe Package Title Time Series Plot Version 0.1.1 Package rtsplot September 15, 2018 A fast and elegant time series visualization package. In addition to the standard R plot tpes, this package supports candle sticks, open-high-low-close, and volume plots. Useful for visualizing an time series data, e.g., stock prices and technical indicators. License MIT + file LICENSE Imports xts, quantmod, zoo, RColorBrewer Suggests TTR URL https://bitbucket.org/rtsvizteam/rtsplot BugReports https://bitbucket.org/rtsvizteam/rtsplot/issues LazLoad es RoxgenNote 6.1.0 NeedsCompilation no Author RTSVizTeam [aut, cph], Irina Kapler [cre] Maintainer Irina Kapler <irkapler@gmail.com> Repositor CRAN Date/Publication 2018-09-15 19:50:03 UTC R topics documented: register.theme........................................ 2 rtsplot............................................ 3 rtsplot.candle........................................ 4 rtsplot.candle.col...................................... 5 rtsplot.corner.label..................................... 6 rtsplot.fake.stock.data.................................... 7 rtsplot.format........................................ 7 1

2 register.theme rtsplot.grid.......................................... 8 rtsplot.hl........................................... 8 rtsplot.laout........................................ 9 rtsplot.legend........................................ 10 rtsplot.lines......................................... 11 rtsplot.matplot........................................ 11 rtsplot.ohlc......................................... 12 rtsplot.scale.volume..................................... 13 rtsplot.stacked........................................ 13 rtsplot.text.......................................... 14 rtsplot.volume........................................ 14 rtsplot.x.highlight...................................... 15 rtsplot..highlight...................................... 15 rtsplot2y.......................................... 16 Index 18 register.theme Theme Setup theme register.theme(grid.color = "gra90", colors = "Set1", col.border = "black", col.up = "green", col.dn = "red", col.x.highlight = "orange", col..highlight = "orange", cex = 1, legend.bg.col = grdevices::adjustcolor("white", 200/255)) rtsplot.theme() rtsplot.theme.set(...) rtsplot.colors(n) grid.color colors col.border col.up color for grid lines, defaults to gra90 RColorBrewer set to generate colors, defaults to "Set1" in RColorBrewer border color for drawing candles, defaults to black up color for drawing candles, defaults to green col.dn down color for drawing candles, defaults to red col.x.highlight color for highlighting along x axis, defaults to orange

rtsplot 3 col..highlight color for highlighting along axis, defaults to orange cex font size, defaults to 1 legend.bg.col background legend color, defaults to grdevices::adjustcolor( white, 200/255)... additional settings n number of colors to generate None rtsplot rtsplot - Time series plot with base R Graphics. Plot time series data with base R Graphics. The rtsplot package is **fast** time series plot package with base R Graphics. rtsplot(, main = NULL, plotx = TRUE, LeftMargin = 0, grid = "x", x.highlight = NULL,.highlight = NULL,.highlight.col = NULL, las = 1, tpe = "l", xlab = "", lab = "", lim = NULL, log = "",...) main plot title plotx flag to displa X axis LeftMargin to plot second Y axis, set LeftMargin=3, defaults to 0 grid which grid lines to draw, defaults to x x.highlight segments to highlight along X axis, defaults to NULL.highlight segments to highlight along Y axis, defaults to NULL.highlight.col color to highlight segments Y axis, defaults to NULL las rotation of Y axis labels, defaults to 1, for more info see par tpe plot tpe, defaults to l, for more info see plot also support ohlc, hl, candle, volume tpes xlab X label, defaults to, for more info see plot lab Y label, defaults to, for more info see plot lim range on Y values, defaults to NULL log log scale x,, x axes, defaults to... additional parameters to the plot

4 rtsplot.candle # generate time series data = rtsplot.fake.stock.data(1000) smbol = 'Test' sma = TTR::SMA(, 250) rsi = TTR::RSI(, 20) # plot candles and RSI charts laout(c(1,1,1,2)) cols = rtsplot.colors(2) rtsplot(, tpe = 'l', plotx = FALSE, col=cols[1],lwd=1.5) rtsplot.lines(sma, col=cols[2], lwd=1.5) rtsplot.legend(c(smbol, 'SMA(250)'), cols[1:2], list(,sma)) # plot rsi rtsplot(rsi, tpe = 'l', lim=c(0,100),.highlight = c(c(0,30), c(70,100)),.highlight.col = grdevices::adjustcolor(c('green','red'), 50/255) ) rtsplot.legend('rsi(20)', 'black', rsi) = rtsplot.fake.stock.data(1000) smbol = 'SPY' # simple example highlight = which( < 10) # plot laout(1) rtsplot.theme.set(col.x.highlight=grdevices::adjustcolor('orange', 200/255)) rtsplot(, tpe = 'l', main = smbol, x.highlight = highlight) rtsplot.candle Create Candle Plot Plot candles if dx is sufficient otherwise ohlc or bars

rtsplot.candle.col 5 rtsplot.candle(, col = rtsplot.candle.col(), border = rtsplot.theme()$col.border) col border color for bars, defaults to rtsplot.candle.col border color, defaults to rtsplot.theme()$col.border = rtsplot.fake.stock.data(100, ohlc=true) smbol = 'SPY' # plot laout(1) rtsplot(, tpe = 'n') rtsplot.candle() rtsplot.legend(smbol, 'black', ) rtsplot.candle.col Bar Colors for Candle and Volume plots Bar Colors for Candle and Volume plots rtsplot.candle.col() rtsplot.volume.col() colors

6 rtsplot.corner.label rtsplot.corner.label Plot corner label Plot corner label, based on the [text at the upper left corner outside of the plot region](http://r.789695.n4.nabble.com/textat-the-upper-left-corner-outside-of-the-plot-region-td885675.html) rtsplot.corner.label(label = NULL, col = "black", x = -1, = 1, xoffset = NA, offset = NA, space = c("plot", "figure"), cex = 1, border = NA) label label col label color x x location, defaults to -1 location, defaults to 1 xoffset x offset, defaults to NA offset offset, defaults to NA space coordinate space, can be "plot" or "figure", defaults to "plot" cex font size, defaults to 1 border border color, defaults to NA - no color rtsplot.theme.set(legend.bg.col=grdevices::adjustcolor('orange', 200/255)) plot(rnorm(20), rnorm(20)) rtsplot.corner.label('test1', =-1, space='figure') rtsplot.corner.label('test2', =1, space='figure') rtsplot.corner.label('test3', x=1, space='figure') rtsplot.corner.label('test4', x=1, =-1, space='figure') rtsplot.theme.set(legend.bg.col=grdevices::adjustcolor('white', 50/255))

rtsplot.fake.stock.data 7 rtsplot.fake.stock.data Genearte fake stock data Generate fake stock data for use in rtsplot examples rtsplot.fake.stock.data(n, 0 = 10, stdev = 0.1, ohlc = FALSE, method = c("normal", "adhoc")) n number of points to generate 0 starting price, defaults to 10 stdev standard deviation, defaults to 0.1 ohlc method with fake stock data generate ohlc data, defaults to FALSE method to generate fake stock data, defaults to normal two methods are implemented: * normal - generate fake stock data assuming returns are normall distributed with zero drift * uniform - generate fake stock data assuming returns are uniforml distributed with zero drift rtsplot.fake.stock.data(10) rtsplot.format Format numbers using 1000 separator Format numbers using 1000 separator rtsplot.format(temp, nround = 2, sprefix = "", eprefix = "")

8 rtsplot.hl temp numbers nround number of rounding digits, defaults to 2 sprefix start prefix string, defaults to eprefix end postfix string, defaults to numbers formatted using 1000 separator rtsplot.grid Add grid to time series plot Add grid to time series plot rtsplot.grid(grid, xaxis.ticks, col = rtsplot.theme()$grid.color) grid xaxis.ticks col which grid lines to draw, defaults to x location of x axis ticks grid color, defaults to rtsplot.theme()$grid.color rtsplot.hl Create HL Plot Create HL Plot rtsplot.hl(, col = rtsplot.volume.col(), border = rtsplot.theme()$col.border)

rtsplot.laout 9 col border color for bars, defaults to rtsplot.volume.col border color, defaults to rtsplot.theme()$col.border = rtsplot.fake.stock.data(100, ohlc=true) smbol = 'SPY' # plot laout(1) rtsplot(, tpe = 'n') rtsplot.hl() rtsplot.legend(smbol, 'black', ) rtsplot.laout Create laout Create laout rtsplot.laout(ilaout, delim = ",") ilaout matrix stored as a string delim delimiter, defaults to,

10 rtsplot.legend rtsplot.legend Plot legend - shortcut to the legend function Plot legend - shortcut to the legend function rtsplot.legend(labels, fill = NULL, lastobs = NULL, x = "topleft", merge = FALSE, bt = "n", border = NA, format = rtsplot.format, cex = 1,...) labels legend labels fill fill colors, defaults to NULL lastobs list of last observations, defaults to NULL x location of legend, defaults to topleft merge merge, defaults to FALSE, see legend function for more info bt box, defaults to n, see legend function for more info border border color, defaults to NA - no color format format Y values function, defaults to rtsplot.format cex font size, defaults to 1... other parameters to legend, see legend function for more info = rtsplot.fake.stock.data(1000) smbol = 'SPY' # plot laout(1) rtsplot(, tpe = 'l', col='black') rtsplot.legend(smbol, 'black', )

rtsplot.lines 11 rtsplot.lines Add lines to time series plot Add lines to time series plot rtsplot.lines(, tpe = "l", col = graphics::par("col"),...) tpe line tpe, defaults to l, for more info see lines col color, defaults to par( col )... additional parameters to the lines = rtsplot.fake.stock.data(1000) smbol = 'SPY' # moving average sma = TTR::SMA(, 250) # plot laout(1) rtsplot(, tpe = 'l', col='black') rtsplot.lines(sma, col='blue', lwd=1.5) rtsplot.legend(c(smbol, 'SMA(250)'), 'black,blue', list(,sma)) rtsplot.matplot matplot version for matplot version for

12 rtsplot.ohlc rtsplot.matplot(, dates = NULL, lim = NULL, tpe = "l", cols = rtsplot.colors(ncol()),...) dates subset of datesdefaults to NULL lim range on Y values, defaults to NULL tpe plot tpe, defaults to l, see plot for details cols colors... additional parameters to the matplot rtsplot.ohlc Create OHLC Plot Plot ohlc if dx is sufficient otherwise bars rtsplot.ohlc(, col = rtsplot.theme()$col.border) col color for bars, defaults to rtsplot.theme()$col.border = rtsplot.fake.stock.data(100, ohlc=true) smbol = 'SPY' # plot laout(1) rtsplot(, tpe = 'n') rtsplot.ohlc() rtsplot.legend(smbol, 'black', )

rtsplot.scale.volume 13 rtsplot.scale.volume Scale volume Scale volume rtsplot.scale.volume() adjusted object rtsplot.stacked Create Stacked plot Create Stacked plot rtsplot.stacked(x,, xlab = "", cols = rtsplot.colors(ncol()), tpe = c("l", "s"), flip.legend = FALSE,...) x xlab cols tpe flip.legend dates object matrix with weights X label, defaults to, for more info see plot colors, defaults to colors rtsplot.theme plot tpe: lines, step stairs c( l, s ) flag to reverse legend order, defaults to FALSE... additional parameters to the plot

14 rtsplot.volume rtsplot.text Add text to time series plot Add text to time series plot rtsplot.text(,...)... additional parameters to the lines = rtsplot.fake.stock.data(1000) smbol = 'SPY' # plot laout(1) rtsplot(, tpe = 'l', col='black') rtsplot.text([100], 'Text', col='red') rtsplot.legend(smbol, 'black', ) rtsplot.volume Plot volume Plot volume rtsplot.volume(, col = rtsplot.volume.col(), border = rtsplot.theme()$col.border)

rtsplot.x.highlight 15 col border color for volume bars color for volume bars border rtsplot.x.highlight Highlight vertical segments Highlight vertical segments rtsplot.x.highlight(, highlight, col = rtsplot.theme()$col.x.highlight) highlight col segments to highlight along X axis highlight color, defaults to rtsplot.control$col.x.highlight rtsplot..highlight Highlight horizontal segments Highlight horizontal segments rtsplot..highlight(highlight, col = rtsplot.theme()$col..highlight) highlight col segments to highlight along Y axis highlight color, defaults to rtsplot.control$col..highlight

16 rtsplot2y # download data data.sp = getsmbols('spy', auto.assign = FALSE) rsi = RSI(Cl(data.sp), 20) #set up two regions for graphs candlestick price data on top 2/3 of the plot #and rsi on the bottom 1/3 of the plot laout(c(1,1,2)) rtsplot(data.sp, tpe = 'candle', plotx = FALSE) rtsplot.legend('spy', 'gre70', data.sp) rtsplot(rsi, tpe = 'l') col = grdevices::adjustcolor(c('green','red'), 80/255) rtsplot..highlight(col=col[1], highlight=c(50,100)) rtsplot..highlight(col=col[2], highlight=c(0,50)) abline(h = 50, col = 'gra20') col = iif(mlast(rsi)>50,'black','red') rtsplot.legend('rsi(20)', col, rsi, text.col=col) rtsplot2y Plot time series with second Y axis Detailed discussion for validit of dual Y axis at [Dual axes time series plots ma be ok sometimes after all](http://freerangestats.info/blog/2016/08/18/dualaxes) rtsplot2y(, las = 1, tpe = "l", col.axis = "red", lim = NULL, log = "",...) las tpe col.axis rotation of Y axis labels, defaults to 1, for more info see par plot tpe, defaults to l, for more info see plot also support ohlc, hl, candle, volume tpes axis color, defaults to red

rtsplot2y 17 lim range on Y values, defaults to NULL log log scale x,, x axes, defaults to... additional parameters to the plot # generate time series data = rtsplot.fake.stock.data(1000) smbol = 'SPY' 1 = rtsplot.fake.stock.data(1000, 100) smbol = 'IBM' # two Y axis example # to plot second Y axis, free some space on left side, set LeftMargin=3 laout(1) cols = c('black', 'red') rtsplot(, tpe = 'l', LeftMargin=3, col=cols[1]) rtsplot2y(1, tpe='l', las=1, col=cols[2], col.axis=cols[2]) rtsplot.legend('spy(rhs),ibm(lhs)', cols, list(,1))

Index legend, 10 lines, 11, 14 matplot, 11, 12 par, 3, 16 plot, 3, 12, 13, 16, 17 register.theme, 2 rtsplot, 3 rtsplot-package (rtsplot), 3 rtsplot.candle, 4 rtsplot.candle.col, 5 rtsplot.colors (register.theme), 2 rtsplot.corner.label, 6 rtsplot.fake.stock.data, 7 rtsplot.format, 7, 10 rtsplot.grid, 8 rtsplot.hl, 8 rtsplot.laout, 9 rtsplot.legend, 10 rtsplot.lines, 11 rtsplot.matplot, 11 rtsplot.ohlc, 12 rtsplot.scale.volume, 13 rtsplot.stacked, 13 rtsplot.text, 14 rtsplot.theme, 13 rtsplot.theme (register.theme), 2 rtsplot.volume, 14 rtsplot.volume.col (rtsplot.candle.col), 5 rtsplot.x.highlight, 15 rtsplot..highlight, 15 rtsplot2y, 16 xts, 3, 5, 7, 9, 11 16 18