marquardt.christian@gmail.com
2005-May-24 18:17 UTC
[Rd] Reversing axis in a log plot (PR#7894)
Full_Name: Christian Marquardt Version: 2.1.0 OS: Linux (Redhat 9) Submission from: (NULL) (151.170.240.10) Following the advice of a reader of R-help, I would now like to submit this as a bug report: Say we have x = seq(1,3, by = 0.01) y = exp(x) Plotting and reversing linear axis is fine plot(x,y) plot(x,y, ylim = c(30,1)) as is a usual log-plot: plot(x,y, log = "y", ylim = c(1,30)) However, plot(x,y, log = "y", ylim = c(30,1)) fails with Error in axis(2, ...) : log - axis(), 'at' creation, _SMALL_ range: invalid {xy}axp or par; axp[0]= 10, usr[0:1]=(34.3721,0.872801) In addition: Warning message: CreateAtVector "log"(from axis()): usr[0] = 34.3721 > 0.872801 = usr[1] ! According to Petr Pikal <petr.pikal -at- precheza.cz>, replacing the ylim argument by ylim = c(30,1.2) helps in the above example; but in my real world applications, it's actually difficult to find a working value for ylim. I hope this is useful, Christian.
ligges@statistik.uni-dortmund.de
2005-May-27 10:32 UTC
[Rd] Reversing axis in a log plot (PR#7894)
Yes, this one is a bug in CreateAtVector, plot.c. It already has the lines: /* Debugging: When does the following happen... ? */ if (umin > umax) warning("CreateAtVector \"log\"(from axis()): " "usr[0] = %g > %g = usr[1] !", umin, umax); And now we know that it happens if (and only if?????) the logarithmic scale is not very small (i.e. axp[2] > 0, this is equal to R's par("yaxp")[3] in your example) and the axis are reversed (umin > umax). I'll try to provide a fix which should be possible by reversing arguments axp and usr in this case and returning a reversed at ... Uwe Ligges marquardt.christian@gmail.com wrote:> Full_Name: Christian Marquardt > Version: 2.1.0 > OS: Linux (Redhat 9) > Submission from: (NULL) (151.170.240.10) > > Following the advice of a reader of R-help, I would now like to submit this as a > bug report: > > Say we have > > x = seq(1,3, by = 0.01) > y = exp(x) > > Plotting and reversing linear axis is fine > > plot(x,y) > plot(x,y, ylim = c(30,1)) > > as is a usual log-plot: > > plot(x,y, log = "y", ylim = c(1,30)) > > However, > > plot(x,y, log = "y", ylim = c(30,1)) > > fails with > > Error in axis(2, ...) : log - axis(), 'at' creation, _SMALL_ range: > invalid {xy}axp or par; > axp[0]= 10, usr[0:1]=(34.3721,0.872801) > In addition: Warning message: > CreateAtVector "log"(from axis()): usr[0] = 34.3721 > 0.872801 = usr[1] ! > > > According to Petr Pikal <petr.pikal -at- precheza.cz>, replacing the ylim > argument by ylim = c(30,1.2) helps in the above example; but in my real world > applications, it's actually difficult to find a working value for ylim. > > I hope this is useful, > > Christian. > > ______________________________________________ > R-devel@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
ligges@statistik.uni-dortmund.de
2005-May-27 11:43 UTC
[Rd] Reversing axis in a log plot (PR#7894)
Please find attached my proposal for a bugfix. The experts might to better, though. Uwe Ligges ligges@statistik.uni-dortmund.de wrote:> Yes, this one is a bug in CreateAtVector, plot.c. > It already has the lines: > > > /* Debugging: When does the following happen... ? */ > if (umin > umax) > warning("CreateAtVector \"log\"(from axis()): " > "usr[0] = %g > %g = usr[1] !", umin, umax); > > > And now we know that it happens if (and only if?????) the logarithmic > scale is not very small (i.e. axp[2] > 0, this is equal to R's > par("yaxp")[3] in your example) and the axis are reversed (umin > umax). > > I'll try to provide a fix which should be possible by reversing > arguments axp and usr in this case and returning a reversed at ... > > Uwe Ligges > > > > > marquardt.christian@gmail.com wrote: > > >>Full_Name: Christian Marquardt >>Version: 2.1.0 >>OS: Linux (Redhat 9) >>Submission from: (NULL) (151.170.240.10) >> >>Following the advice of a reader of R-help, I would now like to submit this as a >>bug report: >> >>Say we have >> >> x = seq(1,3, by = 0.01) >> y = exp(x) >> >>Plotting and reversing linear axis is fine >> >> plot(x,y) >> plot(x,y, ylim = c(30,1)) >> >>as is a usual log-plot: >> >> plot(x,y, log = "y", ylim = c(1,30)) >> >>However, >> >> plot(x,y, log = "y", ylim = c(30,1)) >> >>fails with >> >> Error in axis(2, ...) : log - axis(), 'at' creation, _SMALL_ range: >>invalid {xy}axp or par; >> axp[0]= 10, usr[0:1]=(34.3721,0.872801) >> In addition: Warning message: >> CreateAtVector "log"(from axis()): usr[0] = 34.3721 > 0.872801 = usr[1] ! >> >> >>According to Petr Pikal <petr.pikal -at- precheza.cz>, replacing the ylim >>argument by ylim = c(30,1.2) helps in the above example; but in my real world >>applications, it's actually difficult to find a working value for ylim. >> >>I hope this is useful, >> >> Christian. >> >>______________________________________________ >>R-devel@stat.math.ethz.ch mailing list >>https://stat.ethz.ch/mailman/listinfo/r-devel > > > ______________________________________________ > R-devel@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
maechler@stat.math.ethz.ch
2005-May-30 10:51 UTC
[Rd] Reversing axis in a log plot (PR#7894)
>>>>> "UweL" == Uwe Ligges <ligges@statistik.uni-dortmund.de> >>>>> on Fri, 27 May 2005 11:42:54 +0200 (CEST) writes:UweL> Please find attached my proposal for a bugfix. The UweL> experts might to better, though. UweL> Uwe Ligges Thank you, Uwe! Yes, your fix works, and yes, it can be improved (e.g., no need for the 'atr'; no 'reversed' when in the linear case, ..) Also, there won't be any warning either anymore, since plot(1:3, exp(1:3), xlim = c(30,1)) also gives no warning. You'll find the fixed plot.c in tomorrow's snapshot. Martin BTW: The whole thing {axis reversion} doesn't work in S-plus {doing a non-sensical plot, with tons of warnings}