Dear colleagues, I often use chemical formulas to label my x-axis, e.g. in barplots. I used to do this like the following example and it worked just fine: a <- seq(2,24,2) b <- seq(3,36,3) c <- rbind(a,b) barplot(c, width=c(0.9, 1.1),space=c(0.2, 0.75), col=c("indianred4", "yellow2"), beside = TRUE, xlab="Ions", yaxt="n", xaxt="n", ylab = expression(paste("weighted mean concentration [",mu*eq*l^-1,"]")), ylim = c(0,40)) axis(2,las=2, pos=0.4,at=c(0,10,20,30,40),lab=c(0,10,20,30,40),cex.axis=1.0) axis(1,at=seq(1.8,34.25,2.95), lab=expression(F^{-''}, Cl^{-''}, NO[2]^{-''}, NO[3]^{-''}, PO[4]^{3-''}, SO[4]^{2-''}, Na^{+''}, NH[4]^{+''}, K^{+''}, Mg^{2+''}, Ca^{2+''}, H^{+''}),cex.axis=1.0) The important point is the x-axis here: before we installed the new R 1.5 on our workstations, the chemical formulas were properly aligned and looked well. Ever since, if I use the exact same procedure, I get the graphic but the chemical formulas are not aligned horizontally properly anymore: e.g. Mg^{2+''} or NO[3]^{-''} are a bit higher than F^{-''} or H^{+''} (it seems to depend on whether there is a subscript or a letter with a part below the main line like a 'g'). I didin't find any hint on the r-project homepage. I don't know if we forgot some feature when newly installing R or if something changed in version 1.5. Thanks very much for any hints! Patrick -------------- next part -------------- A non-text attachment was scrubbed... Name: patrick.vcf Type: text/x-vcard Size: 339 bytes Desc: Card for Patrick Buetzberger Url : https://stat.ethz.ch/pipermail/r-help/attachments/20020525/9252070a/patrick.vcf
Hi Patrick You can make you code work by putting a [NULL] at appropriate places. axis(1,at=seq(1.8,34.25,2.95), lab=expression(F[NULL]^{-''}, Cl[NULL]^{-''}, NO[2]^{-''}, NO[3]^{-''}, PO[4]^{3-''}, SO[4]^{2-''}, Na[NULL]^{+''}, NH[4]^{+''}, K[NULL]^{+''}, Mg[NULL]^{2+''}, Ca[NULL]^{2+''}, H[NULL]^{+''}),cex.axis=1.0) I do not understand what causes the behaviour you have observed, and if this is intended (probably someone more clever than me can explain this). Ole Patrick Buetzberger wrote:> > Dear colleagues, > > I often use chemical formulas to label my x-axis, e.g. in barplots. I > used to do this like the following example and it worked just fine: > > a <- seq(2,24,2) > b <- seq(3,36,3) > c <- rbind(a,b) > > barplot(c, width=c(0.9, 1.1),space=c(0.2, 0.75), col=c("indianred4", > "yellow2"), beside = TRUE, > xlab="Ions", yaxt="n", xaxt="n", ylab = expression(paste("weighted mean > concentration [",mu*eq*l^-1,"]")), > ylim = c(0,40)) > > axis(2,las=2, > pos=0.4,at=c(0,10,20,30,40),lab=c(0,10,20,30,40),cex.axis=1.0) > > axis(1,at=seq(1.8,34.25,2.95), lab=expression(F^{-''}, Cl^{-''}, > NO[2]^{-''}, > NO[3]^{-''}, PO[4]^{3-''}, SO[4]^{2-''}, Na^{+''}, NH[4]^{+''}, K^{+''}, > Mg^{2+''}, Ca^{2+''}, H^{+''}),cex.axis=1.0) > > The important point is the x-axis here: before we installed the new R > 1.5 on our workstations, the chemical formulas were properly aligned and > looked well. Ever since, if I use the exact same procedure, I get the > graphic but the chemical formulas are not aligned horizontally properly > anymore: e.g. Mg^{2+''} or NO[3]^{-''} are a bit higher than F^{-''} or > H^{+''} (it seems to depend on whether there is a subscript or a letter > with a part below the main line like a 'g'). > I didin't find any hint on the r-project homepage. I don't know if we > forgot some feature when newly installing R or if something changed in > version 1.5. > > Thanks very much for any hints! > > Patrick-- Ole F. Christensen Department of Mathematics and Statistics Fylde College, Lancaster University Lancaster, LA1 4YF, England -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Sat, 25 May 2002, Patrick Buetzberger wrote:> Dear colleagues, > > I often use chemical formulas to label my x-axis, e.g. in barplots. I > used to do this like the following example and it worked just fine: ><snip>> > The important point is the x-axis here: before we installed the new R > 1.5 on our workstations, the chemical formulas were properly aligned and > looked well. Ever since, if I use the exact same procedure, I get the > graphic but the chemical formulas are not aligned horizontally properly > anymore: e.g. Mg^{2+''} or NO[3]^{-''} are a bit higher than F^{-''} or > H^{+''} (it seems to depend on whether there is a subscript or a letter > with a part below the main line like a 'g'). > I didin't find any hint on the r-project homepage. I don't know if we > forgot some feature when newly installing R or if something changed in > version 1.5.I think something changed. In the NEWS file we have o The vertical alignment of mathematical annotations was wrong. When a vertical adjustment was not given, it was bottom-adjusting i.e,. it was treating adj=0 as adj=c(0, 0). It now treats adj=0 as adj=c(0, 0.5) as for "normal" text. (PR#1302) and I expect this is responsible. It looks to me as if R is now trying to center the expressions vertically. This is also consistent with the previous reply that suggested putting blank subscripts on everything as a work-around. I don't think there's a complete fix for this, since sometimes people want expressions aligned on their actual vertical centers and sometimes on the center of the main line of text (as you do). -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
[moved to R-devel] Thomas Lumley wrote:> > On Sat, 25 May 2002, Patrick Buetzberger wrote: > > > Dear colleagues, > > > > I often use chemical formulas to label my x-axis, e.g. in barplots. I > > used to do this like the following example and it worked just fine: > > > <snip> > > > > The important point is the x-axis here: before we installed the new R > > 1.5 on our workstations, the chemical formulas were properly aligned and > > looked well. Ever since, if I use the exact same procedure, I get the > > graphic but the chemical formulas are not aligned horizontally properly > > anymore: e.g. Mg^{2+''} or NO[3]^{-''} are a bit higher than F^{-''} or > > H^{+''} (it seems to depend on whether there is a subscript or a letter > > with a part below the main line like a 'g'). > > I didin't find any hint on the r-project homepage. I don't know if we > > forgot some feature when newly installing R or if something changed in > > version 1.5. > > I think something changed. In the NEWS file we have > > o The vertical alignment of mathematical annotations was wrong. > When a vertical adjustment was not given, it was bottom-adjusting > i.e,. it was treating adj=0 as adj=c(0, 0). It now treats > adj=0 as adj=c(0, 0.5) as for "normal" text. (PR#1302) > > and I expect this is responsible.That change indeed is reasonable, but I don't think it is this particular change (at least as documented) that makes Patrick's example doesn't work any more.> It looks to me as if R is now trying to center the expressions vertically.Right for text() and friends, but not for axis(), see the example below, and maybe this is a bug (Paul?). Anyway, fixing this bug (?) won't change much for Patrick's example.> This is also consistent with the previous reply that suggested putting blank > subscripts on everything as a work-around.If sub- or superscripts are a expression, space is added below respective above that expression (if not already done before), so complex formulas can be generated. And, at least for me, the result is somehow expected. I am very surprised and wondered why Patrick's example worked in R-1.4.1. Without having looked into the code, there must have been something fuzzy that is broken since R-1.5.0.> I don't think there's a complete fix for this, since sometimes people want > expressions aligned on their actual vertical centers and sometimes on the > center of the main line of text (as you do).Here an example on the alignments: plot(1:12, type="n", axes=FALSE) expr <- expression(F^{-''}, Cl^{-''}, NO[2]^{-''}, NO[3]^{-''}, PO[4]^{3-''}, SO[4]^{2-''}, Na^{+''}, NH[4]^{+''}, K^{+''}, Mg^{2+''}, Ca^{2+''}, H^{+''}) axis(1, 1:12, lab=expr) # the "problem" text(1:12, 3, expr) # adj=c(0.5, 0.5), the default for text() # This looks like the x-axis annotation: text(1:12, 5, expr, adj=c(0.5, 0)) # And this is all in *one* formula, as Patrick would like to get it somehow. # Only a guess: Was there something like a "coerce to one formula" in R-1.4.1? text(6, 9, labels = expression(F^{-''} * Cl^{-''} * NO[2]^{-''} * NO[3]^{-''} * PO[4]^{3-''} * SO[4]^{2-''} * Na^{+''} * NH[4]^{+''} * K^{+''} * Mg^{2+''} * Ca^{2+''} * H^{+''})) I am sure, Paul will get the point in less than a second. Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._