rtsplot2Y: Plot time series with second Y axis

View source: R/rtsplot.r

rtsplot2YR Documentation

Plot time series with second Y axis

Description

Detailed discussion for validity of dual Y axis at [Dual axes time series plots may be ok sometimes after all](http://freerangestats.info/blog/2016/08/18/dualaxes)

Usage

rtsplot2Y(y, las = 1, type = "l", col.axis = "red", ylim = NULL, log = "", ...)

Arguments

y

xts object

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

col.axis

axis color, defaults to 'red'

ylim

range on Y values, defaults to NULL

log

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

...

additional parameters to the plot

Value

nothing

Examples

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

y1 = rtsplot.fake.stock.data(1000, 100)
symbol = 'IBM'
	
 # two Y axis example
 # to plot second Y axis, free some space on left side, set LeftMargin=3
 layout(1)
 cols = c('black', 'red')

 rtsplot(y, type = 'l', LeftMargin=3, col=cols[1])
			
 rtsplot2Y(y1, type='l', las=1, col=cols[2], col.axis=cols[2])

 rtsplot.legend('SPY(rhs),IBM(lhs)', cols, list(y,y1))


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