Problems to get a ctree plot (library party) in a file via jpeg/png

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Problems to get a ctree plot (library party) in a file via jpeg/png

Carlos Ortega
Hello All,

I am using library "party" and I have found a curious/strange behaviour when
trying to save the output of a ctree in a file via jpeg/png command.

If you use:

################
library(party)
airq <- subset(airquality, !is.na(Ozone))
airct <- ctree(Ozone ~ ., data = airq)
plot(airct, terminal_panel = node_boxplot, drop_terminal = FALSE)
###############

you get a perfect and nice graph, but when you try the equivalent but trying
to put the output in a file:

#################
library(party)
airq <- subset(airquality, !is.na(Ozone))
airct <- ctree(Ozone ~ ., data = airq)

jpeg(filename = "Rplot%03d.jpg", width = 1400, height = 800,
     pointsize = 12, quality = 75, bg = "white", res = NA)
      plot(airct, terminal_panel = node_boxplot, drop_terminal = FALSE)
 dev.off()
 ################

you will see that the boxplots at the terminal nodes do not appear...

On the other hand, when you try a similar approach with

##################
 plot(airct, terminal_panel = node_boxplot, drop_terminal = FALSE)
  savePlot(file=paste(directorio,"PartyTree",sep=""),type="jpeg", device=
dev.cur())
  dev.off()
#################

you get everything perfectly fine, although with a lower resolution.

I am using the latest version available of your library (0.8-1) in a Windows
box.

Do you know if this is the expected behaviour or there is something abnormal
?

###########
platform i386-pc-mingw32
arch     i386
os       mingw32
system   i386, mingw32
status
major    2
minor    2.1
year     2005
month    12
day      20
svn rev  36812
language R

###########
Package *party* version 0.8-1

I checked this problem directly with the package creators/maintainers and
they recommended to post it here.
They have also provided very kindly a workaround while it is finally
corrected.

Thanks,
Carlos Ortega.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problems to get a ctree plot (library party) in a file via jpeg/png

Achim Zeileis
Carlos:

> I am using library "party" and I have found a curious/strange behaviour when
> trying to save the output of a ctree in a file via jpeg/png command.

thanks for reporting this. We've seen this problem before with the vcd
package. The reason is that the default background is usually
"transparent" whereas for jpeg() and png() devices it is "white". That has
the effect that the
  grid.rect()
command at the end of node_boxplot() not only draws the bounding rectangle
but also fills it with "white", thus hiding the actual boxplots. The fix
is to use
  grid.rect(gp = gpar(fill = "transparent"))
instead. We'll commit a fixed party to CRAN asap.

Best wishes,
Z

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Loading...