Dear All, wonder if you could help with the following:we have:vals <- 1:5names(vals) <- paste0("ke",1:length(vals))mp <- barplot(vals, ylim = c(0, 6),ylab=expression(paste("Hour"^"-10"))) In would like to make the numbers (ke1 to ke5, respectively) in the labels of the x axis a subscript. There is plenty info on making subscripts in the title of the axis (ie: xlab=expression(...)), but was unable to find directions for my problem... Appreciate your help, Andras [[alternative HTML version deleted]]
Andras, There may be an easier way to do this, but this works. vals <- 1:5 names(vals) <- paste0("ke",1:length(vals)) mp <- barplot(vals, ylim = c(0, 6), ylab=expression(Hour^-10), names.arg="") sapply(vals, function(i) axis(1, at=mp[i], substitute(list(ke[x]), list(x=i)), tick=FALSE)) Jean On Fri, Oct 3, 2014 at 6:15 AM, Andras Farkas <motyocska at yahoo.com> wrote:> Dear All, > wonder if you could help with the following:we have:vals <- 1:5names(vals) > <- paste0("ke",1:length(vals))mp <- barplot(vals, ylim = c(0, > 6),ylab=expression(paste("Hour"^"-10"))) > > In would like to make the numbers (ke1 to ke5, respectively) in the labels > of the x axis a subscript. There is plenty info on making subscripts in the > title of the axis (ie: xlab=expression(...)), but was unable to find > directions for my problem... Appreciate your help, > Andras > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
On 03 Oct 2014, at 13:15 , Andras Farkas <motyocska at yahoo.com> wrote:> Dear All, > wonder if you could help with the following:we have:vals <- 1:5names(vals) <- paste0("ke",1:length(vals))mp <- barplot(vals, ylim = c(0, 6),ylab=expression(paste("Hour"^"-10"))) > > In would like to make the numbers (ke1 to ke5, respectively) in the labels of the x axis a subscript. There is plenty info on making subscripts in the title of the axis (ie: xlab=expression(...)), but was unable to find directions for my problem... Appreciate your help, > Andras > [[alternative HTML version deleted]]Some ideas: e <- as.expression(lapply(as.double(1:5), function(i)bquote("ke"[.(i)]))) plot(1:5, xaxt="n") axis(1, at=1:5, labels=e) barplot(rpois(5, 5), names=e)> > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com