[R] Skip jumps in curve
Leo Mada
|eo@m@d@ @end|ng |rom @yon|c@eu
Tue Feb 13 19:44:20 CET 2024
Dear Duncan,
Thank you very much for the response. I suspected that such an option has not been implemented yet.
The plot was very cluttered due to those vertical lines. Fortunately, the gamma function is easy to handle. But the feature remains on my wishlist as useful more in general.
Sincerely,
Leonard
________________________________
From: Duncan Murdoch <murdoch.duncan using gmail.com>
Sent: Tuesday, February 13, 2024 6:05 PM
To: Leo Mada <leo.mada using syonic.eu>; r-help using r-project.org <r-help using r-project.org>
Subject: Re: [R] Skip jumps in curve
On 13/02/2024 10:29 a.m., Leo Mada via R-help wrote:
> Dear R-Users,
>
> Is there a way to skip over without plotting the jumps/discontinuities in curve()?
>
> I have not seen such an option, but maybe I am missing something.
>
> plot.gamma = function(xlim = c(-6, -1), ylim = c(-1,3), hline = NULL, n = 1000) {
> curve(gamma(x), from = xlim[1], to = xlim[2], ylim=ylim, n=n);
> if( ! is.null(hline)) abline(h = hline, col = "green");
> }
>
> Euler = 0.57721566490153286060651209008240243079;
> plot.gamma(hline = Euler)
>
> Adding an option to the function curve may be useful:
> options = c("warn", "silent", "unconnected")
>
> This is part of some experiments in math; but that's another topic. For latest version:
> https://github.com/discoleo/R/blob/master/Math/Integrals.Gamma.Inv.R
If you know where the discontinuities are, plot multiple times with the
discontinuities as endpoints:
plot.gamma = function(xlim = c(-6, -1), ylim = c(-1,3), hline = NULL, n
= 1000) {
start <- floor(xlim[1]):floor(xlim[2])
end <- start + 1
start[1] <- xlim[1]
end[length(end)] <- xlim[2]
n <- round(n/length(start))
curve(gamma(x), from = start[1], to = end[1], ylim=ylim, n=n, xlim =
xlim)
for (i in seq_along(start)[-1])
curve(gamma(x), from = start[i], to = end[i], add = TRUE, n)
if( ! is.null(hline)) abline(h = hline, col = "green");
}
Euler = 0.57721566490153286060651209008240243079;
plot.gamma(hline = Euler)
If you don't know where the discontinuities are, it would be much
harder, because discontinuities can be hard to detect unless the jumps
are really big.
Duncan Murdoch
[[alternative HTML version deleted]]
More information about the R-help
mailing list