rtsplot: 'rtsplot' - Time series plot with base R Graphics.

rtsplotR Documentation

'rtsplot' - Time series plot with base R Graphics.

Description

Plot time series data with base R Graphics.

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

Usage

rtsplot(
  y,
  main = NULL,
  plotX = TRUE,
  LeftMargin = 0,
  grid = "xy",
  x.highlight = NULL,
  y.highlight = NULL,
  y.highlight.col = NULL,
  las = 1,
  type = "l",
  xlab = "",
  ylab = "",
  ylim = NULL,
  log = "",
  skip.breaks = FALSE,
  xaxis.map = rtsplot.create.xaxis.map,
  ...
)

Arguments

y

xts object

main

plot title

plotX

flag to display X axis

LeftMargin

to plot second Y axis, set LeftMargin=3, defaults to 0

grid

which grid lines to draw, defaults to 'xy'

x.highlight

segments to highlight along X axis, defaults to NULL

y.highlight

segments to highlight along Y axis, defaults to NULL

y.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

type

plot type, defaults to 'l', for more info see plot also support 'ohlc', 'hl', 'candle', 'volume' types

xlab

X label, defaults to ”, for more info see plot

ylab

Y label, defaults to ”, for more info see plot

ylim

range on Y values, defaults to NULL

log

log scale x, y, xy axes, defaults to ”

skip.breaks

flag to skip plotting missing date/times (i.e. nights and weekends), defaults to FALSE

xaxis.map

xaxis map function used if skip.breaks is TRUE, defaults to rtsplot.create.xaxis.map

...

additional parameters to the plot

Value

nothing

Author(s)

Maintainer: Irina Kapler irkapler@gmail.com

Authors:

See Also

Useful links:

Examples

# generate time series data
y = rtsplot.fake.stock.data(1000)
symbol = 'Test'

sma = TTR::SMA(y, 250)
rsi = TTR::RSI(y, 20)	

# plot candles and RSI charts
layout(c(1,1,1,2))
cols = rtsplot.colors(2)
	
rtsplot(y, type = 'l', plotX = FALSE, col=cols[1],lwd=1.5)
	rtsplot.lines(sma, col=cols[2], lwd=1.5)
	rtsplot.legend(c(symbol, 'SMA(250)'), cols[1:2], list(y,sma))
	
# 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)


y = rtsplot.fake.stock.data(1000)
symbol = 'SPY'
	
 # simple example
 highlight = which(y < 10)

 # plot
 layout(1)
 rtsplot.theme.set(col.x.highlight=grDevices::adjustcolor('orange', 200/255))
		
 rtsplot(y, type = 'l', main = symbol, x.highlight = highlight)


 # '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')
 


rtsplot documentation built on Sept. 24, 2023, 1:07 a.m.