[R] plot.window: need finite 'ylim' values

David Winsemius dw|n@em|u@ @end|ng |rom comc@@t@net
Sun Aug 23 19:19:33 CEST 2020


You are using a function whose help page says it is "highly experimental". In such cases it is probably better to contact the package maintainer with a feature request. The DESCRIPTION file says contact should be through one of 

http://www.quantmod.com 
https://github.com/joshuaulrich/quantmod



-- 
David.
> On Aug 20, 2020, at 10:55 AM, Mike <mike9 using posteo.nl> wrote:
> 
> Dear R users,
> 
> I have already asked this in r-sig-finance (not getting a solution)
> but it seems to be plot-related anyway.
> 
> I like to plot several financial charts to files with an identical
> layout according to "indicators" so the charts can be browsed
> quickly.
> 
> quantmod::chart_Series is a function to plot a financially-related
> chart in the upper part and zero or more indicators below. Normally
> these indicators would be assigned defined values at least in some
> part of the subset/window to be plotted, which is fine for plot. But
> if all observations are NA chart_Series throws
> 
> Error in plot.window(c(1, 31), c(NaN, NaN)) : need finite 'ylim' values
> 
> While this outcome for plot/plot.window may be intended for most
> applications it is undesirable here. Getting a blank subwindow here is
> intended if the indicator is completely NA (at least in the subset to
> be plotted).
> 
> This post
> https://stat.ethz.ch/pipermail/r-sig-finance/2020q3/015000.html
> suggests to generate the plot object with chart_Series and then to
> explicitly set x$Env$ylim[[4]] before plotting - without success.
> 
> Can I tell plot/plot.window to ignore such errors and simply generate
> an empty region instead?
> 
> Thanks
> Mike
> 
> 
> My minimal reproducible:
> 
> library(quantmod)
> 
> my_plot_function <- function () {
>  data (sample_matrix)
>  sample.xts <- as.xts (sample_matrix[1:50,'Close'], dateFormat="POSIXct")
>  sample.xts <- cbind (sample.xts, NA)
>  sample.xts[50,2] <- 0
>  colnames (sample.xts) <- c('Close', 'Indicator')
> 
>  # Indicator
>  ta <- list ("add_TA(sample.xts[,2])")
> 
>  # In the range to be plotted ta is completely NA 
>  subset <- '2007-01-10::2007-01-30'
> 
>  plot (chart_Series (sample.xts[,1], subset=subset, TA=ta))
> }
> 
> my_plot_function ()
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list