Nothing
## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
## ----setup--------------------------------------------------------------------
suppressPackageStartupMessages(require(dplyr))
suppressPackageStartupMessages(require(data.table))
suppressPackageStartupMessages(require(stringr))
suppressPackageStartupMessages(require(FinanceGraphs))
## ----echo=FALSE---------------------------------------------------------------
options(datatable.print.keys=FALSE, datatable.print.class=FALSE)
knitr::opts_chunk$set(fig.width = 7)
## ----echo=FALSE---------------------------------------------------------------
mtcars=data.table(datasets::mtcars,keep.rownames=TRUE)
mtcars=mtcars[,id:= stringr::str_split_i(rn," ",-1)]
## -----------------------------------------------------------------------------
head(mtcars,2)
fg_scatplot(mtcars,"disp ~ hp + color:cyl + label:id","scatter",title="mtcars")
## -----------------------------------------------------------------------------
fg_scatplot(mtcars,"disp ~ hp + color:cyl + symbol:gear + size:am","scatter",title="mtcars")
## -----------------------------------------------------------------------------
set.seed(1); ndates<-400
samp_rw <- function() { 100*(1+cumsum(rnorm(ndates,sd=0.2/sqrt(260)))) }
dts <- seq(as.Date("2021-01-01"),as.Date("2021-01-01")+ndates-1)
dttest_A <- data.table(date=dts,ccat="A vs X",px_idx=samp_rw(),px_eq=samp_rw())
dttest_B <- copy(dttest_A)[,let(ccat="B vs X",px_eq=samp_rw())]
dttest <- rbind(dttest_A, dttest_B)
## -----------------------------------------------------------------------------
fg_scatplot(dttest,"px_eq ~ px_idx + color:ccat + doi:recent + point:label","scatter",
datecuts=c(66,122),title="from recent")
## -----------------------------------------------------------------------------
dtrtn<- rbind(eqtyrtn[,.(date,r_eq=100*EEM,r_idx=100*QQQ,ticker="EEM")],
eqtyrtn[,.(date,r_eq=100*IBM,r_idx=100*QQQ,ticker="IBM")]) |>
narrowbydtstr("-1y::")
fg_scatplot(dtrtn,"r_eq ~ r_idx + color:ticker + xline:0 + yline:0","densitylm",
tformula="y~0+x:(x>0)",title="piecewise linear")
## -----------------------------------------------------------------------------
toplot = eqtypx[data.table(consumer_sent),on=.(date),roll=T] |> tail(n=12)
fg_scatplot(toplot,"QQQ ~ price + point:value","path",title="QQQ vs Sent",axislabels="ConsSent;Stonks")
## -----------------------------------------------------------------------------
fg_scatplot(mtcars,"disp ~ hp + text:id","scatter",title="boundbox Example",
boundboxtype="probidentify",boundbox=c(0.1,0.1))
## -----------------------------------------------------------------------------
fg_scatplot(dttest,"px_eq ~ px_idx + color:ccat ","scat",title="with decorations",
annotatecorners="NW;NE;SE;SW",
xdecoration="mktsad;mkthappy",ydecoration="eqsad;eqhappy")
## -----------------------------------------------------------------------------
require(ggplot2)
fg_scatplot(dttest,"px_eq ~ px_idx + point:value","scat",keepcols="ccat") + facet_wrap(ccat ~ .)
## -----------------------------------------------------------------------------
fg_get_aes("lines",n_max=3)
## -----------------------------------------------------------------------------
fg_print_aes_list("fg_scatplot") |> head(n=5)
## -----------------------------------------------------------------------------
head(fg_get_aes("altlines_6"),2)
fg_scatplot(dttest,"px_eq ~ px_idx + color:ccat,altlines_6 + point:label","scatter",title="from recent")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.