r - Y axis scaling issue with small numbers -
i have issue y-scaling numbers smaller 1e-10 : appear on same horizontal line.
here reproducible example :
file <- structure(list(i = c(-7.254574e-11, -5.649333e-11, -5.015416e-11, -4.228137e-11, -3.287486e-11, -2.714915e-11, -2.203692e-11, -1.784489e-11, -1.150574e-11, -1.058553e-11, -6.189018e-12, -3.735149e-12, -2.303724e-12, 6.610914e-13, 1.274374e-12, -3.610768e-13, 5.465134e-12, 6.691699e-12, 8.020478e-12, 1.139353e-11, 1.537988e-11, 1.926399e-11, 2.130825e-11, 2.45791e-11, 3.204071e-11, 3.582262e-11, 4.287535e-11, 4.624839e-11, 5.16657e-11, 6.035387e-11), v = c(-2, -1.867, -1.733, -1.6, -1.467, -1.333, -1.2, -1.067, -0.933, -0.8, -0.667, -0.533, -0.4, -0.267, -0.133, 0, 0.133, 0.267, 0.4, 0.533, 0.667, 0.8, 0.933, 1.067, 1.2, 1.333, 1.467, 1.6, 1.733, 1.867)), .names = c("i", "v"), class = "data.frame", row.names = c(na, -30l)) plot(file$v,file$i) gg <- ggplot(file,aes(x = v,y=i)) print(gg + geom_point()) as can see, using base plot function points displayed correctly while using ggplot2 displayed on horizontal line.
i saw similar post on mailing list in may 2011, hadley answered worked development version of ggplot2. however, using r version described below still error.
> sessioninfo() r version 2.15.0 (2012-03-30) platform: i686-pc-linux-gnu (32-bit) locale: [1] lc_ctype=fr_fr.utf-8 lc_numeric=c lc_time=fr_fr.utf-8 [4] lc_collate=fr_fr.utf-8 lc_monetary=fr_fr.utf-8 lc_messages=fr_fr.utf-8 [7] lc_paper=c lc_name=c lc_address=c [10] lc_telephone=c lc_measurement=fr_fr.utf-8 lc_identification=c attached base packages: [1] stats graphics grdevices utils datasets methods base other attached packages: [1] tikzdevice_0.6.2 filehash_2.2-1 scales_0.2.0 plyr_1.7.1 reshape2_1.2.1 [6] ggplot2_0.9.0 loaded via namespace (and not attached): [1] colorspace_1.1-1 dichromat_1.2-4 digest_0.5.2 grid_2.15.0 mass_7.3-18 [6] memoise_0.1 munsell_0.3 proto_0.3-9.2 rcolorbrewer_1.0-5 stringr_0.6 [11] tools_2.15.0 anyone has clue ?
thank in advance ! thibaud ruelle
as brian diggs commented in response a related post @joran pointed above, problem's being caused function scales::zero_range(). uses all.equal() test whether smallest , largest y-values within tolerance = .machine$double.eps ^ 0.5 = 1.490116e-08 of 1 another; if are, data plotted "zero scale" used in example.
as temporary fix, can use fixinnamespace() remove offending bit of zero_range().
library(scales) ## (the scales package needs on search path) fixinnamespace("zero_range", pos="package:scales") in editor launched fixinnamespace(), replace definition of zero_range():
function (x) { length(x) == 1 || istrue(all.equal(x[1] - x[2], 0)) } with 1 (making sure save edited version):
function (x) { length(x) == 1 } the code supplied runs fine:

Comments
Post a Comment