Learn R Programming


title: "rtsplot"

rtsplot

Time series plot with base R Graphics

The rtsplot package is fast time series plot package with base R Graphics.

Installation:

The current release is available on CRAN, which you can install via:

install.packages("rtsplot")

To install the development version run following code:

remotes::install_bitbucket("rtsvizteam/rtsplot")

Example :

	library(quantmod)
	
	symbol = 'AAPL'
	data = getSymbols(symbol, src = 'yahoo',  auto.assign=F)
	
	library(rtsplot)
	y = data['2007::']
	sma = TTR::SMA(Cl(y), 250)
	rsi = TTR::RSI(Cl(y), 20)	

	# plot candles and volume and table
	layout(c(1,1,1,1,2,3))
	cols = rtsplot.colors(2)
		
	rtsplot(y, type = 'l', plotX = F, col=cols[1],lwd=1.5, log='y')
		rtsplot.lines(sma, col=cols[2], lwd=1.5)
		rtsplot.legend(c(symbol, 'SMA(250)'), cols[1:2], list(y,sma))
		
		
	y = rtsplot.scale.volume(y)
	rtsplot(y, type = 'volume', plotX = F, col = 'darkgray')
		rtsplot.legend('Volume', 'darkgray', Vo(y))
		
		
	# plot rsi
	rtsplot(rsi, type = 'l', ylim=c(0,100),
		y.highlight = c(c(0,30), c(70,100)),
		y.highlight.col = grDevices::adjustcolor(c('green','red'), 50/255)
	)	
	rtsplot.legend('RSI(20)', 'black', rsi)

Example skip.breaks flag: skip plotting missing date/times (i.e. nights and weekends)

	library(rtsplot)
	
	# 'skip.breaks' example with daily data
	y = rtsplot.fake.stock.data(10, remove.non.trading = TRUE)
  
	layout(1:2)
	rtsplot(y, type='b')
		rtsplot.legend('skip.breaks=FALSE', text.col='red')
	rtsplot(y, type='b', skip.breaks=TRUE)
		rtsplot.legend('skip.breaks=TRUE', text.col='red')

	# 'skip.breaks' example with intra-day data
	y = rtsplot.fake.stock.data(5*24*60, period = 'minute', remove.non.trading = TRUE)

	layout(1:2)
	rtsplot(y, type='l')
		rtsplot.legend('skip.breaks=FALSE', text.col='red')
	rtsplot(y, type='l', skip.breaks=TRUE)
		rtsplot.legend('skip.breaks=TRUE', text.col='red')

Copy Link

Version

Install

install.packages('rtsplot')

Monthly Downloads

255

Version

0.1.5

License

MIT + file LICENSE

Maintainer

Irina Kapler

Last Published

September 24th, 2023

Functions in rtsplot (0.1.5)

rtsplot.stacked

Create Stacked plot
rtsplot.format

Format numbers using 1000 separator
rtsplot.text

Add text to time series plot
rtsplot

`rtsplot` - Time series plot with base R Graphics.
rtsplot.hl

Create HL Plot
rtsplot.candle

Create Candle Plot
rtsplot.grid

Add grid to time series plot
rtsplot.corner.label

Plot corner label
rtsplot.layout

Create layout
rtsplot.fake.stock.data

Generate fake stock data
rtsplot.legend

rtsplot.candle.col

Bar Colors for Candle and Volume plots
rtsplot.polygon

Add polygon to time series plot
register.theme

Theme
rtsplot.lines

Add lines to time series plot
rtsplot.scale.volume

Scale volume
rtsplot.y.highlight

Highlight horizontal segments
rtsplot.matplot

matplot version for xts object
rtsplot2Y

Plot time series with second Y axis
rtsplot.ohlc

Create OHLC Plot
rtsplot.volume

Plot volume
rtsplot.x.highlight

Highlight vertical segments