Re: [R] Plotting question: Problem with strwidth in 2.7.1

From: Lauri Nikkinen <lauri.nikkinen_at_iki.fi>
Date: Mon, 30 Jun 2008 16:03:07 +0300

Sorry, I found that there is a new bmp() device and when I lower the resolution parameter e.g. to 72, everything works fine.

Best
Lauri

2008/6/30, Lauri Nikkinen <lauri.nikkinen_at_iki.fi>:
> R users,
>
> I have a problem with function strwidth in 2.7.1. I'm trying to set
> the plot margins in a way that horizontal
> column labels will fit to the graph. tmp.t is a list of data.frame
> objects. This code works well in 2.6.0.
>
> ...snip..
> library(gplots)
> for (i in names(tmp.t)) {
> bmp(filename=paste(i, "_", Sys.Date(), ".bmp", sep=""),
> width=1038, height=820, res=1200)
> maxim <- max(strwidth(as.character(colnames(tmp.t[[i]])),
> units="inches"))*4.5
> opar <- par(mar=c(3,maxim,2,2), bg="white", cex=1.6, oma =
> c(0, 0, 2, 0), mgp=c(3,0.5,0), xpd=TRUE)
> colo <- c("red", "lightblue1", "orange", "yellow")
> xmax <- max(unlist(lapply(tmp.t[i], function(x) apply(x, 2,
> sum))) + 15)
> bar <- barplot2(tmp.t[[i]],
> horiz=TRUE,
> names.arg=as.character(colnames(tmp.t[[i]])),
> las=1,
> cex.names=0.7,
> cex.main=0.9,
> cex.axis=0.7,
> xlim=c(0, xmax),
> col=colo,
> plot.grid = TRUE
> )
> box()
> dev.off()
> }
> ...snip...
>
> Now running this script I get an error message
>
> Error in plot.new() : figure margins too large
>
> I found from http://cran.r-project.org/src/base/NEWS that
>
> o Use of strwidth/height(units="user") (the default) is again an
> error before a user coordinate system has been set on the
> device, rather than giving nonsensical values (the effect of
> r31367).
>
> Does this have something to do with my problem? How should I modify my
> code to get it work in R 2.7.1?
>
> Thanks
> Lauri
>
> > sessionInfo()
> R version 2.7.1 (2008-06-23)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=Finnish_Finland.1252;LC_CTYPE=Finnish_Finland.1252;LC_MONETARY=Finnish_Finland.1252;LC_NUMERIC=C;LC_TIME=Finnish_Finland.1252
>
> attached base packages:
> [1] tcltk stats graphics grDevices utils datasets methods
> [8] base
>
> other attached packages:
> [1] TeachingDemos_2.2 tkrplot_0.0-18 gplots_2.6.0 gdata_2.4.2
> [5] gtools_2.5.0 RODBC_1.2-3
>
> loaded via a namespace (and not attached):
> [1] tools_2.7.1
>



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. Received on Mon 30 Jun 2008 - 14:01:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 30 Jun 2008 - 14:30:49 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive