p.tscol {metools} | R Documentation |
Bar plot in time serie format
Description
p.tscol make a bar plot in time serie format. The data don't need be a ts object.
Usage
p.tscol(
data,
xaxis,
yaxis,
dateformat = "%Y-%m",
datebreaks = "1 month",
ybreaks = 10,
percent = FALSE,
yaccuracy = 0.01,
ydecimalmark = ".",
title = "Title",
xlab = "X axis",
ylab = "Y axis",
stitle = NULL,
note = NULL,
ctitles = "black",
cscales = ctitles,
cbgrid = "white",
clgrid = cbgrid,
cplot = "white",
cserie = "black",
cbserie = cserie,
cticks = "black",
lwdserie = 1,
pnote = 1,
cbord = cplot,
titlesize = 20,
wordssize = 12,
snote = 11,
xlim = NULL
)
Arguments
data |
a dataframe |
xaxis |
x axis data |
yaxis |
y axis data |
dateformat |
format of date in x axis (need a dataformat string) (default ="%Y-%m") |
datebreaks |
datebreaks in x axis (default="1 month") |
ybreaks |
number of y axis breaks (default=10) |
percent |
If TRUE y axis in percent (default=F) |
yaccuracy |
a round for y axis (default=0.01) |
ydecimalmark |
y decimal mark (default=".") |
title |
title of plot |
xlab |
x axis label |
ylab |
y axis label |
stitle |
subtitle |
note |
note |
ctitles |
color of titles (title,xlab,ylab) |
cscales |
color of the scales (default= same ctitles) |
cbgrid |
color of grid background |
clgrid |
color of grid lines |
cplot |
color of plot background |
cserie |
color of serie |
cbserie |
color of serie border (default= same cserie) |
cticks |
color of axis ticks |
lwdserie |
size of serie |
pnote |
position of note (default=1) (only numbers) |
cbord |
color of plot border (default= same cplot) |
titlesize |
size of title (default=20) (only numbers) |
wordssize |
size of words (default=12) (only numbers) |
snote |
size of note (default=11) (only numbers) |
xlim |
limit of x axis (default=NULL) |
Value
Return a graphic.
Examples
v=data.frame("x"=seq.Date(as.Date('2020-01-01'),
to = as.Date('2020-04-01'),by='month'),"y"=c(5,3,7,2))
p.tscol(v,v$x,v$y,title="Simple example")
p.tscol(v,v$x,v$y,dateformat="%B",title="Example with colorbyvar",
ylab="Values",xlab=NULL,cserie=p.colorbyvar(v$y))
v=data.frame("x"=seq.Date(as.Date('2020-01-01'),
to = as.Date('2020-04-01'),by='month'),"y"=c(0.03,-0.05,0.08,-0.02))
p.tscol(v,v$x,v$y,percent=TRUE,title="Example with percent data",xlab=NULL,ylab=NULL)
p.tscol(v,v$x,v$y,percent=TRUE,yaccuracy=1,title="y accuracy set",xlab=NULL,ylab=NULL)
p.tscol(v,v$x,v$y,percent=TRUE,yaccuracy=1,title="Example with colorbypositive",xlab=NULL,ylab=NULL,
cserie=p.colorbypositive(v$y),cbserie="black",lwdserie=1) #lwdserie change the board in this case