Seite 1 von 1

Rpy und Paket "playwith" macht probleme

Verfasst: Dienstag 1. September 2009, 16:17
von The Spirit
Hi.
Ich nutze R für Statistikzwecke und darin das Paket playwith.
Alles läuft einwandfrei, außer ich will zum schluss die mit R und playwith generierte Grafik speichern.
Wenn ich das ganze nur in R mache, klappt es einwandfrei.
Jemand vielleicht ne Idee, was das sein könnte?
Thx

Verfasst: Dienstag 1. September 2009, 19:41
von CM
Du magst uns nicht noch ein paar Details verraten?
(RPy oder RPy2? Was ist der Code? Was ggf. ist die Fehlermeldung?)

Gruß,
Christian

Verfasst: Mittwoch 2. September 2009, 08:50
von The Spirit
ups, hab ich in der eile vergessen.

ich nutze:

- python 2.5.2 (wegen mysql anbindung)
- rpy 1.0.3
- R 2.7.0

Code: Alles auswählen

from rpy import r
r.library("playwith")

r.assign("var", values)

#make playwith plot

r("""
	playwith({
		plot(var, xlab = "Daten", ylab = "Werte", pch = ".")
		lines(var)
		}, title = "Auswertung")
	"""
)
values ist dabei eine liste mit float werten.

das proble ist jetzt nur, das der plot ja angezeigt, ich daran rummalen und zoomen kann. auch das ausdrucken klappt.
will ich den plot aber speichern, dann "blockiert" das playwith fenster und ich kann es nur noch abschießen und bekomm keine fehlermeldung in python.

Verfasst: Mittwoch 2. September 2009, 10:43
von CM
Hm, in der Tat. Da scheint ein Bug in playwith zu sein. (Habe nie wirklich genutzt, weshalb es mir nicht auffiel.) Immerhin, ich erhalte einen Traceback:

Code: Alles auswählen

 *** caught segfault ***
address 0x48, cause 'memory not mapped'

Traceback:
 1: print.default("/home/cm/Desktop/test.ps")
 2: print("/home/cm/Desktop/test.ps")
 3: do.call(h$action, list(h$file))
 4: handler(h)
 5: .gfile(toolkit, text = text, type = type, initialfilename = initialfilename,     filter = filter, handler = handler, action = action, ...)
 6: .gfile(toolkit, text = text, type = type, initialfilename = initialfilename,     filter = filter, handler = handler, action = action, ...)
 7: gfile("Export plot to image file", type = "save", filter = filter,     initialfilename = myDefault)
 8: function (widget, playState) {    playFreezeGUI(playState)    on.exit(playThawGUI(playState))    myExt <- playwith.getOption("save.as.format")    myDefault <- if (!is.null(playState$title))         playState$title    else playState$callName    myDefault <- paste(myDefault, myExt, sep = ".")    okExt <- c("pdf", "png", "jpg", "jpeg", "tif", "tiff", "ps",         "eps", "svg", "wmf", "emf", "fig")    filter <- list(`All files` = list(patterns = c("*")), PDF = list(patterns = c("*.pdf")),         `PNG (bitmap)` = list(patterns = c("*.png")), EPS = list(patterns = c("*.eps")),         SVG = list(patterns = c("*.svg")), `WMF (metafile)` = list(patterns = c("*.wmf",             "*.emf")), JPEG = list(patterns = c("*.jpg", "*.jpeg")),         TIFF = list(patterns = c("*.tif", "*.tiff")), xfig = list(patterns = c("*.fig")))    filename <- gfile("Export plot to image file", type = "save",         filter = filter, initialfilename = myDefault)    if (is.na(filename))         return()    ext <- tolower(get.extension(filename))    if ((ext %in% okExt) == FALSE) {        filename <- paste(filename, myExt, sep = ".")        ext <- myExt    }    playDevSet(playState)    w.in <- dev.size("in")[1]    h.in <- dev.size("in")[2]    ps <- playState$pointsize    devName <- switch(ext, pdf = "pdf", ps = , eps = "postscript",         png = "Cairo_png", jpeg = , jpg = "jpeg", tiff = , tif = "tiff",         svg = "Cairo_svg", wmf = , emf = "win.metafile", fig = "xfig",         {            gmessage.error("Unrecognised filename extension")            stop("Unrecognised filename extension")        })    devFun <- get(devName, mode = "function")    callNm <- if (ext == "eps")         "dev.copy2eps"    else "dev.copy"    devCall <- call(callNm, device = devFun, file = filename,         width = w.in, height = h.in, pointsize = ps)    if (!is.null(formals(devFun)$units))         devCall$units <- "in"    eval(devCall)    dev.off()}(<pointer: 0x59e81c0>, <environment>)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 
Vielleicht kannst Du das dem Felix Andrews (siehe http://code.google.com/p/playwith/ ) zusenden und ihn bitten das zu fixen? (Habe selbst zu viele andere Dinge um die Ohren.)

Meine Settings:
Ubuntu 9.04
Python 2.6.2
R 2.8.1
rpy 1.0.3
playwith 0.9-44 von CRAN.

Wäre schön, wenn Du hier posten könntest, wie es weiter geht.

Oder hat jemand eine andere Idee, wie der Traceback zu interpretieren ist, bzw. was zu tun ist?

Gruß,
Christian

Verfasst: Mittwoch 2. September 2009, 10:44
von CM
PS Mit numpy arrays funktioniert es überhaupt nicht.