[R] lattice change font of one specific axis label in each panel
David Winsemius
dwinsemius at comcast.net
Thu Mar 27 22:51:42 CET 2014
On Mar 27, 2014, at 2:34 PM, David Winsemius wrote:
>
> On Mar 27, 2014, at 8:11 AM, el_alisio wrote:
>
>> Hi Kevin,
>>
>> thanks for the advice! The code is now reproducible. Sorry!
>
> No, it is not, since you can only read it on Nabble, yecch. There is some sort of weird format stuff that Nabble does that prevents code from appearing on Rhelp copies.
>
>
>> Actually I wanted to print only one x-label ("All Postdoctorates") in bold
>> face, not all of them. This would be easily achieved, if "All
>> Postdoctorates" appeared always in the same row of each panel, but this is
>> not the case here.
>>
>
p1 <- dotplot(prop.table(postdoc, margin = 1), groups = FALSE,
xlab = "Proportion", layout = c(1, 5), aspect = 0.6,
scales = list(y = list(relation = "free", rot = 0) ),
prepanel = function(x, y) {
list(ylim = levels(reorder(y, x)))
},
panel = function(x, y, ...) {
panel.dotplot(x, reorder(y, x), ...)
},
yscale.components = function(...){
temp <- yscale.components.default(...)
loc <- temp$left$labels$at
# print( removed debugging print line
temp$left$labels$labels <-
sapply( temp$left$labels$labels,
function(x) if(grepl("All", x)){
as.expression(bquote( bold(.(x))))
}else{
as.expression(bquote(.(x)))}
)
temp }
)
print(p1)
I suppose taking out the debugging code might be wise, see above. I had previously emailed Deepayan to inquire why `bquote` expressions would not succeed in lattice without applying a further `as.expression` and he said he that what was returned from `bquote` wasn't really an R expression, but rather an unevaluated call. I thought I should be able to get this to work but if failed to apply the blding but tit did print the labels:
......
function(x) if(grepl("All", x)){
+ substitute( bold(x), list(x=x))
+ }else{
+ substitute( x, list(x=x))}
.......
--
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list