plot_ts: Plot time series !PLEASE USE plot_dts!

Description Usage Arguments Details See Also Examples

View source: R/plot_ts.R

Description

Plot time series !PLEASE USE plot_dts!

Usage

1
2
3
4
5
6
7
8
plot_ts(dt, type = "auto", col = "auto", lty = par("lty"),
  lwd = par("lwd"), pch = par("pch"), legend = c("topright", "topleft",
  "bottomright", "bottomleft", "n"), last_values = TRUE, main = "",
  ylim = "auto", xlim = "auto", time_range = "auto",
  resolution = "auto", log = par("ylog"), mar = par("mar"),
  xaxt = par("xaxt"), add = par("new"))

t_to_x(t)

Arguments

dt

data.table with date/time index represented by first column. If OHLC detected then only candles plotted. Use lines for the rest of data

type

type vector or single value. Same as in plot but 'candle' supports. Default is 'l'. 'h' triggers adding zero to plot range

col

color vector or single value. Default is 'auto' so colors generated automatically

lty, lwd, pch

parameters vectors or single values. Same as in plot

legend

position of plot legend. Supported positions are 'topright','topleft','bottomright','bottomleft' or 'n' to hide legend

last_values

whether to add last values marks to the right of the plot. If vector specified marks added only for columns specified in vector

main

title of the plot. Default is ''

ylim

y range of data to plot

xlim

x range of data to plot

time_range

time range in format 'HH:MM:SS/HH:MM:SS'

resolution

frequency of time marks on time axis. Supported resolutions are 'auto','minute','hour','day','month','year','years'. Default is 'auto'

log

should y axis be in logarithmic scale?

mar

same as in par

xaxt

same as in par

add

add to existing plot?

t

date/time vector to be converted to plot x coordinates

Details

Plots time series each represented by columns of times_series on single plot.
As for OHLC series, only one can be plotted and should be passed as times_series with 4 columns 'open','high','low','close'.

See Also

Other graphical functions: add_last_values, add_legend, distinct_colors, empty_plot, hist_dt, lines_ohlc, lines_stacked_hist, multi_heatmap, plot_table

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
data( ticks )

time_series = to_candles( ticks, 60 * 10 )

plot_ts( time_series[ time %bw% '2016-05-13', list( time, open, high, low, close ) ] )
plot_ts( time_series[ time %bw% '2016-05-13', list( time, volume = volume / 1e6 )  ] , type = 'h' )
plot_ts( time_series[ time %bw% '2016-05', list( time, close ) ] )
plot_ts( time_series[ , list( time, close ) ] )



mar = par( 'mar' )
par( mar = c( 0, 4, 0, 4 ), xaxt = 'n' )
layout ( matrix( 1:(3 + 2) ), heights = c( 1, 4, 2, 2, 1 ) )
  empty_plot()
  plot_ts( time_series[ , list( time, open, high, low, close ) ] )
  plot_ts( time_series[ , list( time, close ) ] )
  par( xaxt = 's' )
  plot_ts( time_series[ , list( time, volume = volume / 1e6 ) ], type = 'h' )
  empty_plot()
par( mar = mar )
layout( matrix(1) )

QuantTools documentation built on Oct. 23, 2020, 7:54 p.m.