Dear R developer,
I am not quite sure, if I should post my concern as a wish to
r-bugs at r-project.org. Thus, as recommended, I first send an email to you.
My request is the following: I would appreciate, if it was possible to
obtain a plot of a 'stepfun' with a strict interpretation of xlim.
What I mean:
sf <- stepfun(1:4, 1:5)
plot(sf, xlim=c(0,10))
does not bound the function to the horizontal area from 0 to 10, but
continues drawing outside this interval.
Another situation: I want to add a stepfun to an existing plot:
plot(c(0, 50), c(0, 10), type = "n")
lines(sf, xlim = c(0,10))
The left and right ends of the line drawing are chosen quite arbitrary
instead of using the exact xlim information.
In the code of plot.stepfun it is the variable 'dr' in conjuction with
ti <- c(xlim[1L] - dr, knF, xlim[2L] + dr)
which determine and alter the x-range of the stepfun internally.
What do you think of this issue?
Best regards,
Sebastian Meyer
stricter use of xlim in plot.stepfun
3 messages · Sebastian Meyer, Jim Lemon
Sebastian Meyer wrote:
Dear R developer, I am not quite sure, if I should post my concern as a wish to r-bugs at r-project.org. Thus, as recommended, I first send an email to you. My request is the following: I would appreciate, if it was possible to obtain a plot of a 'stepfun' with a strict interpretation of xlim. What I mean: sf <- stepfun(1:4, 1:5) plot(sf, xlim=c(0,10)) does not bound the function to the horizontal area from 0 to 10, but continues drawing outside this interval. Another situation: I want to add a stepfun to an existing plot: plot(c(0, 50), c(0, 10), type = "n") lines(sf, xlim = c(0,10)) The left and right ends of the line drawing are chosen quite arbitrary instead of using the exact xlim information. In the code of plot.stepfun it is the variable 'dr' in conjuction with ti <- c(xlim[1L] - dr, knF, xlim[2L] + dr) which determine and alter the x-range of the stepfun internally.
Hi Sebastian, Have a look at par(xaxs="i"), which you can pass to the plot function as well. Jim
Jim wrote:
Have a look at par(xaxs="i"), which you can pass to the plot function as well.
Hi everybody, Thank you very much for your suggestion, Jim. I did not think of that graphical parameter "xaxs". It would really be a workaround for my first example. Unfortunately, it does not solve the second situation, where I would like to add the step function to an existing plot within a specified region. Internally, 'xlim' will always be expanded by 'dr' (=diff(xlim)) units to the left and to the right. Perhaps one could add an argument to the plot.stepfun function, with which one can specify this 'dr' variable (see the internals of plot.stepfun) ? Best regards, Sebastian