Dietrich.Trenkler at uni-osnabrueck.de
2007-Jul-20 10:57 UTC
[Rd] Bug in dev.print ? (PR#9801)
Ladies and Gentlemen, the following piece of code causes an annoying error: > aa <- structure(list(BG = c(24, 16, 61, 30, 37, 33, 13, 4, -34, + 10, 33, 41, 6, 32, 39, 37, 36, -17, 60, 35, 22, 21, 29, 52, + 41, 62, -26, 30, -33, 27, 34, 28, 36, 29, -12, 38, 34, 32, + 40, 36, 39, 31, 19, 55, 28, 40, 38, 39, -31, 64, -22, 41, + 37, -33, 18, 31, 1, -33, 28, 36, -22), Kont = c(4, 7, 3, + 4, 6, 3, 4, 7, 7, 7, 2, 3, 4, 3, 3, 6, 3, 2, 6, 6, 4, 3, + 3, 4, 6, 4, 2, 1, 2, 4, 6, 6, 3, 4, 7, 6, 3, 6, 6, 6, 6, + 2, 7, 6, 4, 3, 6, 4, 5, 6, 7, 6, 3, 7, 7, 4, 4, 5, 6, 2, + 2), Jan = c(25, 31, -4, 15, 13, 12, 32, 20, 30, 30, 18, 1, + 30, 15, 8, 16, 7, 27, -3, 15, 20, 26, 18, -15, 8, -36, 25, + 19, 27, 18, 17, 21, 15, 9, 25, 14, 19, 19, 11, 17, 15, 18, + 21, -3, 19, 4, 14, 2, 32, 2, 29, 12, 13, 29, 30, 8, 30, 26, + 21, 15, 31), Feb = c(28, 31, -1, 16, 14, 14, 33, 19, 28, + 29, 18, 2, 32, 16, 7, 17, 8, 26, -3, 15, 21, 26, 20, -9, + 9, -29, 25, 21, 28, 21, 18, 21, 16, 10, 27, 16, 18, 18, 13, + 18, 15, 21, 23, -4, 24, 5, 15, 6, 30, 2, 30, 13, 15, 26, + 30, 11, 31, 28, 21, 17, 30), Mrz = c(30, 31, -1, 19, 17, + 19, 35, 19, 26, 30, 20, 9, 32, 21, 14, 19, 12, 27, 2, 18, + 23, 26, 23, 1, 12, -10, 24, 23, 27, 25, 20, 23, 23, 13, 26, + 18, 19, 20, 16, 19, 18, 24, 25, 3, 30, 9, 17, 12, 32, 4, + 30, 15, 17, 26, 30, 14, 32, 25, 23, 20, 29), Apr = c(35, + 31, 5, 21, 20, 23, 36, 19, 22, 30, 20, 16, 32, 25, 15, 21, + 14, 26, 9, 20, 26, 28, 26, 7, 16, 3, 22, 27, 24, 28, 22, + 23, 25, 16, 24, 20, 19, 20, 18, 22, 20, 24, 27, 12, 37, 14, + 20, 21, 25, 6, 29, 18, 17, 23, 30, 18, 32, 23, 23, 22, 26), + Mai = c(40, 32, 12, 27, 26, 26, 34, 19, 18, 31, 22, 21, 32, + 29, 22, 23, 22, 24, 16, 24, 30, 28, 30, 16, 22, 13, 19, + 32, 20, 27, 27, 24, 33, 20, 21, 22, 21, 21, 23, 25, 25, + 29, 26, 19, 40, 21, 24, 27, 23, 9, 26, 24, 20, 19, 31, + 24, 32, 20, 24, 28, 24), Jun = c(41, 32, 17, 33, 30, + 29, 34, 18, 16, 31, 25, 26, 31, 32, 27, 26, 28, 20, 20, + 27, 32, 29, 32, 23, 27, 21, 17, 35, 18, 29, 31, 26, 38, + 23, 18, 27, 22, 23, 31, 29, 29, 34, 25, 23, 39, 28, 28, + 30, 19, 12, 26, 28, 22, 15, 31, 27, 31, 17, 25, 32, 22), + Jul = c(42, 33, 19, 35, 33, 30, 34, 18, 14, 32, 26, 29, 31, + 36, 32, 29, 28, 21, 24, 30, 33, 30, 34, 23, 30, 26, 17, + 35, 18, 28, 33, 27, 39, 22, 19, 29, 25, 25, 34, 32, 32, + 37, 24, 25, 36, 29, 30, 32, 18, 14, 25, 29, 22, 15, 32, + 32, 31, 17, 28, 34, 21), Aug = c(43, 33, 17, 35, 33, + 31, 34, 18, 16, 32, 27, 28, 30, 35, 30, 29, 26, 23, 21, + 30, 32, 31, 34, 20, 29, 21, 20, 35, 18, 28, 33, 28, 39, + 21, 18, 30, 25, 26, 33, 31, 32, 37, 24, 22, 34, 29, 29, + 31, 19, 14, 26, 29, 22, 17, 32, 31, 31, 19, 28, 34, 24), + Sep = c(43, 33, 13, 32, 29, 28, 33, 18, 19, 33, 26, 25, 31, + 32, 26, 26, 24, 28, 17, 27, 31, 30, 32, 16, 25, 11, 23, + 34, 19, 28, 31, 28, 34, 20, 19, 28, 25, 26, 28, 28, 29, + 33, 23, 17, 35, 24, 27, 27, 20, 11, 26, 26, 24, 18, 32, + 29, 31, 22, 28, 29, 28), Okt = c(37, 32, 5, 27, 24, 23, + 32, 18, 21, 32, 24, 17, 31, 25, 17, 23, 17, 29, 9, 24, + 29, 29, 27, 5, 20, -5, 25, 29, 21, 26, 27, 26, 27, 17, + 20, 22, 22, 24, 21, 24, 25, 28, 23, 9, 33, 18, 25, 19, + 22, 6, 27, 22, 21, 22, 32, 23, 32, 21, 27, 27, 31), Nov = c(31, + 32, -2, 21, 18, 18, 32, 19, 25, 32, 21, 10, 31, 19, 11, + 19, 11, 27, 2, 20, 26, 28, 21, -5, 15, -24, 25, 25, 25, + 23, 23, 25, 19, 12, 22, 17, 21, 21, 13, 20, 18, 23, 22, + 0, 28, 13, 19, 10, 28, 4, 27, 17, 17, 26, 31, 17, 31, + 23, 25, 20, 31), Dez = c(27, 32, -4, 16, 14, 11, 31, + 19, 29, 30, 19, 2, 31, 14, 7, 17, 7, 27, 0, 16, 22, 27, + 16, -13, 10, -35, 25, 20, 26, 21, 18, 22, 14, 9, 23, + 14, 19, 20, 11, 17, 16, 20, 22, -3, 23, 6, 17, 3, 30, + 3, 29, 14, 15, 29, 31, 10, 30, 26, 23, 18, 33)), .Names = c("BG", + "Kont", "Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", + "Aug", "Sep", "Okt", "Nov", "Dez"), row.names = c("Abu Dhabi ", + "Acapulco ", "Anchorage ", "Antalya ", + "Athen ", "Atlanta ", "Bangkok ", + "Bogota ", "BuenosAires ", "Caracas ", + "Casablanca ", "Chicago ", "ColomboSriLanka ", + "Dallas ", "Denver ", "FaroAlgarve ", + "GrandCanyonArizona ", "Harare ", "Helsinki ", + "HeraklionKreta ", "Hongkong ", "Honolulu ", + "Houston ", "Irkutsk ", "Istanbul ", + "JakutskNordostsibirien", "Johannesburg ", "Kairo ", + "Kapstadt ", "Kathmandu ", "LarnakaZypern ", + "Las Palmas ", "Las Vegas ", "Lhasa ", + "Lima ", "Lissabon ", "Los Angeles ", + "Madeira ", "Madrid ", "Malaga ", + "Mallorca ", "Marrakesch ", "Mexico City ", + "Moskau ", "Neu Delhi ", "New York ", + "Palermo ", "PekingBeijing ", "PerthAustralien ", + "Reykjavik ", "RioDeJaneiro ", "Rom ", + "SanFrancisco ", "SantiagoDeChile ", "SantoDomingoKaribik ", + "Shanghai ", "Singapur ", "SydneyAustralien ", + "Teneriffa ", "Tunis ", "Windhoek "), + class = "data.frame") > > attach(aa) > par(mfrow=c(4,3)) > m <-c("Januar","Februar","M?rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember") > for(i in 1:12) + plot(BG,aa[,i+2],main=m[i],xlab="Breitengrad",ylab="Temperatur",ylim=c(-35,35)) > dev.print(device = postscript, width=4,height=5,horizontal=TRUE,file="c://test.ps") windows 2 > # That's fine > # Here comes the error > dev.print(device = postscript, width=5 ,height=4,horizontal=TRUE,file="c://test.ps") Error in dev.copy(device = function (file = ifelse(onefile, "Rplots.ps", : invalid graphics state > # From now on plotting is impossible: > plot(1:2) Error in plot.new() : figure margins too large > # As a "remedy" I restart R --please do not edit the information below-- Version: platform = i386-pc-mingw32 arch = i386 os = mingw32 system = i386, mingw32 status major = 2 minor = 5.0 year = 2007 month = 04 day = 23 svn rev = 41293 language = R version.string = R version 2.5.0 (2007-04-23) Windows XP (build 2600) Service Pack 2.0 Locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 Search Path: .GlobalEnv, aa, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, package:methods, Autoloads, package:base -- Dietrich Trenkler c/o Universitaet Osnabrueck Rolandstr. 8; D-49069 Osnabrueck, Germany email: Dietrich.Trenkler at Uni-Osnabrueck.de
Dietrich.Trenkler at uni-osnabrueck.de wrote:> Ladies and Gentlemen, > > the following piece of code causes an annoying error: > > > > aa <- structure(list(BG = c(24, 16, 61, 30, 37, 33, 13, 4, -34, > + 10, 33, 41, 6, 32, 39, 37, 36, -17, 60, 35, 22, 21, 29, 52, > + 41, 62, -26, 30, -33, 27, 34, 28, 36, 29, -12, 38, 34, 32, > + 40, 36, 39, 31, 19, 55, 28, 40, 38, 39, -31, 64, -22, 41, > + 37, -33, 18, 31, 1, -33, 28, 36, -22), Kont = c(4, 7, 3, > + 4, 6, 3, 4, 7, 7, 7, 2, 3, 4, 3, 3, 6, 3, 2, 6, 6, 4, 3, > + 3, 4, 6, 4, 2, 1, 2, 4, 6, 6, 3, 4, 7, 6, 3, 6, 6, 6, 6, > + 2, 7, 6, 4, 3, 6, 4, 5, 6, 7, 6, 3, 7, 7, 4, 4, 5, 6, 2, > + 2), Jan = c(25, 31, -4, 15, 13, 12, 32, 20, 30, 30, 18, 1, > + 30, 15, 8, 16, 7, 27, -3, 15, 20, 26, 18, -15, 8, -36, 25, > + 19, 27, 18, 17, 21, 15, 9, 25, 14, 19, 19, 11, 17, 15, 18, > + 21, -3, 19, 4, 14, 2, 32, 2, 29, 12, 13, 29, 30, 8, 30, 26, > + 21, 15, 31), Feb = c(28, 31, -1, 16, 14, 14, 33, 19, 28, > + 29, 18, 2, 32, 16, 7, 17, 8, 26, -3, 15, 21, 26, 20, -9, > + 9, -29, 25, 21, 28, 21, 18, 21, 16, 10, 27, 16, 18, 18, 13, > + 18, 15, 21, 23, -4, 24, 5, 15, 6, 30, 2, 30, 13, 15, 26, > + 30, 11, 31, 28, 21, 17, 30), Mrz = c(30, 31, -1, 19, 17, > + 19, 35, 19, 26, 30, 20, 9, 32, 21, 14, 19, 12, 27, 2, 18, > + 23, 26, 23, 1, 12, -10, 24, 23, 27, 25, 20, 23, 23, 13, 26, > + 18, 19, 20, 16, 19, 18, 24, 25, 3, 30, 9, 17, 12, 32, 4, > + 30, 15, 17, 26, 30, 14, 32, 25, 23, 20, 29), Apr = c(35, > + 31, 5, 21, 20, 23, 36, 19, 22, 30, 20, 16, 32, 25, 15, 21, > + 14, 26, 9, 20, 26, 28, 26, 7, 16, 3, 22, 27, 24, 28, 22, > + 23, 25, 16, 24, 20, 19, 20, 18, 22, 20, 24, 27, 12, 37, 14, > + 20, 21, 25, 6, 29, 18, 17, 23, 30, 18, 32, 23, 23, 22, 26), > + Mai = c(40, 32, 12, 27, 26, 26, 34, 19, 18, 31, 22, 21, 32, > + 29, 22, 23, 22, 24, 16, 24, 30, 28, 30, 16, 22, 13, 19, > + 32, 20, 27, 27, 24, 33, 20, 21, 22, 21, 21, 23, 25, 25, > + 29, 26, 19, 40, 21, 24, 27, 23, 9, 26, 24, 20, 19, 31, > + 24, 32, 20, 24, 28, 24), Jun = c(41, 32, 17, 33, 30, > + 29, 34, 18, 16, 31, 25, 26, 31, 32, 27, 26, 28, 20, 20, > + 27, 32, 29, 32, 23, 27, 21, 17, 35, 18, 29, 31, 26, 38, > + 23, 18, 27, 22, 23, 31, 29, 29, 34, 25, 23, 39, 28, 28, > + 30, 19, 12, 26, 28, 22, 15, 31, 27, 31, 17, 25, 32, 22), > + Jul = c(42, 33, 19, 35, 33, 30, 34, 18, 14, 32, 26, 29, 31, > + 36, 32, 29, 28, 21, 24, 30, 33, 30, 34, 23, 30, 26, 17, > + 35, 18, 28, 33, 27, 39, 22, 19, 29, 25, 25, 34, 32, 32, > + 37, 24, 25, 36, 29, 30, 32, 18, 14, 25, 29, 22, 15, 32, > + 32, 31, 17, 28, 34, 21), Aug = c(43, 33, 17, 35, 33, > + 31, 34, 18, 16, 32, 27, 28, 30, 35, 30, 29, 26, 23, 21, > + 30, 32, 31, 34, 20, 29, 21, 20, 35, 18, 28, 33, 28, 39, > + 21, 18, 30, 25, 26, 33, 31, 32, 37, 24, 22, 34, 29, 29, > + 31, 19, 14, 26, 29, 22, 17, 32, 31, 31, 19, 28, 34, 24), > + Sep = c(43, 33, 13, 32, 29, 28, 33, 18, 19, 33, 26, 25, 31, > + 32, 26, 26, 24, 28, 17, 27, 31, 30, 32, 16, 25, 11, 23, > + 34, 19, 28, 31, 28, 34, 20, 19, 28, 25, 26, 28, 28, 29, > + 33, 23, 17, 35, 24, 27, 27, 20, 11, 26, 26, 24, 18, 32, > + 29, 31, 22, 28, 29, 28), Okt = c(37, 32, 5, 27, 24, 23, > + 32, 18, 21, 32, 24, 17, 31, 25, 17, 23, 17, 29, 9, 24, > + 29, 29, 27, 5, 20, -5, 25, 29, 21, 26, 27, 26, 27, 17, > + 20, 22, 22, 24, 21, 24, 25, 28, 23, 9, 33, 18, 25, 19, > + 22, 6, 27, 22, 21, 22, 32, 23, 32, 21, 27, 27, 31), Nov = c(31, > + 32, -2, 21, 18, 18, 32, 19, 25, 32, 21, 10, 31, 19, 11, > + 19, 11, 27, 2, 20, 26, 28, 21, -5, 15, -24, 25, 25, 25, > + 23, 23, 25, 19, 12, 22, 17, 21, 21, 13, 20, 18, 23, 22, > + 0, 28, 13, 19, 10, 28, 4, 27, 17, 17, 26, 31, 17, 31, > + 23, 25, 20, 31), Dez = c(27, 32, -4, 16, 14, 11, 31, > + 19, 29, 30, 19, 2, 31, 14, 7, 17, 7, 27, 0, 16, 22, 27, > + 16, -13, 10, -35, 25, 20, 26, 21, 18, 22, 14, 9, 23, > + 14, 19, 20, 11, 17, 16, 20, 22, -3, 23, 6, 17, 3, 30, > + 3, 29, 14, 15, 29, 31, 10, 30, 26, 23, 18, 33)), .Names = c("BG", > + "Kont", "Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", > + "Aug", "Sep", "Okt", "Nov", "Dez"), row.names = c("Abu > Dhabi ", > + "Acapulco ", "Anchorage ", > "Antalya ", > + "Athen ", "Atlanta ", > "Bangkok ", > + "Bogota ", "BuenosAires ", > "Caracas ", > + "Casablanca ", "Chicago ", > "ColomboSriLanka ", > + "Dallas ", "Denver ", > "FaroAlgarve ", > + "GrandCanyonArizona ", "Harare ", > "Helsinki ", > + "HeraklionKreta ", "Hongkong ", > "Honolulu ", > + "Houston ", "Irkutsk ", > "Istanbul ", > + "JakutskNordostsibirien", "Johannesburg ", > "Kairo ", > + "Kapstadt ", "Kathmandu ", > "LarnakaZypern ", > + "Las Palmas ", "Las Vegas ", > "Lhasa ", > + "Lima ", "Lissabon ", "Los > Angeles ", > + "Madeira ", "Madrid ", > "Malaga ", > + "Mallorca ", "Marrakesch ", "Mexico > City ", > + "Moskau ", "Neu Delhi ", "New > York ", > + "Palermo ", "PekingBeijing ", > "PerthAustralien ", > + "Reykjavik ", "RioDeJaneiro ", > "Rom ", > + "SanFrancisco ", "SantiagoDeChile ", > "SantoDomingoKaribik ", > + "Shanghai ", "Singapur ", > "SydneyAustralien ", > + "Teneriffa ", "Tunis ", > "Windhoek "), > + class = "data.frame") > > > > attach(aa) > > par(mfrow=c(4,3)) > > m > <-c("Januar","Februar","M?rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember") > > for(i in 1:12) > + > plot(BG,aa[,i+2],main=m[i],xlab="Breitengrad",ylab="Temperatur",ylim=c(-35,35)) > > dev.print(device = postscript, > width=4,height=5,horizontal=TRUE,file="c://test.ps") > windows > 2 > > # That's fine > > # Here comes the error > > dev.print(device = postscript, width=5 > ,height=4,horizontal=TRUE,file="c://test.ps") > Error in dev.copy(device = function (file = ifelse(onefile, "Rplots.ps", : > invalid graphics state > > # From now on plotting is impossible: > > plot(1:2) > Error in plot.new() : figure margins too large > > # As a "remedy" I restart R > >There's a generic issue when dev.print() goes wrong in that it leaves the target device open. Have a look at dev.list() and possibly use dev.off() for a less drastic remedy. I'm not at a Windows machine so I'm unsure whether the "invalid graphics state" is an issue in itself or it is just that you set the figure region so that there is no room for both the figure region and the margins.> > --please do not edit the information below-- > > Version: > platform = i386-pc-mingw32 > arch = i386 > os = mingw32 > system = i386, mingw32 > status > major = 2 > minor = 5.0 > year = 2007 > month = 04 > day = 23 > svn rev = 41293 > language = R > version.string = R version 2.5.0 (2007-04-23) > > Windows XP (build 2600) Service Pack 2.0 > > Locale: > LC_COLLATE=English_United States.1252;LC_CTYPE=English_United > States.1252;LC_MONETARY=English_United > States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 > > Search Path: > .GlobalEnv, aa, package:stats, package:graphics, package:grDevices, > package:utils, package:datasets, package:methods, Autoloads, package:base > > >