joshuaulrich / xts

Extensible time series class that provides uniform handling of many R time series classes by extending zoo.
http://joshuaulrich.github.io/xts/
GNU General Public License v2.0
220 stars 71 forks source link

Should we have range_label flag to suppress data range heading? #288

Closed binhpham79 closed 5 years ago

binhpham79 commented 5 years ago

Description

Hi Team,

By default the plot will add heading indicating data range automatically. But in some application such as econ we usually work with annual / quarterly / monthly data so that this heading is noisy due to its date format.

I think we just need a flag likes if range_label = TRUE (default) will be print the heading, else range_label = FALSE the heading is just "" (empty).

Of course, it is quite easy but I wish the team accepts this feature.

Thank you and best regards,

Expected behavior

  if (range_label == TRUE) {
  text.exp <- c(expression(text(xlim[1],0.5,main,font=2,col=theme$labels,offset=0,cex=1.1,pos=4)),
                expression(text(xlim[2],0.5,
                                paste(start(xdata[xsubset]),end(xdata[xsubset]),sep=" / "),
                                col=theme$labels,adj=c(0,0),pos=2)))
  }
  else {
  text.exp <- c(expression(text(xlim[1],0.5,main,font=2,col=theme$labels,offset=0,cex=1.1,pos=4)),
                expression(text(xlim[2],0.5,
                                paste(""),
                                col=theme$labels,adj=c(0,0),pos=2)))
  } 
  cs$add(text.exp, env=cs$Env, expr=TRUE)
joshuaulrich commented 5 years ago

Thanks for the report! This is very similar to #247, so I'm going to close it as a duplicate. It will be addressed when the other ticket is solved.