ggplot2 doesn't produce a plot in rapache

206 views
Skip to first unread message

bsteves

unread,
Aug 25, 2010, 6:52:13 PM8/25/10
to rapache
I've been able to install rapache on my Ubuntu computer and things
seem to work fine until I try to plot with the ggplot2 package.

The following code using brew works fine and I return a nice plot
image. However when I replace plot(A,B) with qplot(A,B) only a blank
image is created. The code itself works just fine from the R
terminal.

<%
library(ggplot2)
library(Cairo)
A<-rnorm(10, sd=5)
B<-rnorm(10, sd=5)
Cairo(file="/var/www/images/plot.png", type="png", width = 480, height
= 480)
plot(A,B)
dev.off()
%>
<img src="/images/plot.png"/>
<pre><code>
<%
print(.packages())
%>
</code>
</pre>

I've also included a print command in my code to list all the loaded
packages. This code renders the following so I don't believe I'm
failing to load the proper packages due to permission errors.

[1] "ggplot2" "proto" "grid" "reshape" "plyr"
"Cairo"
[7] "brew" "stats" "graphics" "grDevices" "utils"
"datasets"
[13] "methods" "base"


Any thoughts on why qplot or any of the other functions in ggplot2
might not be working. I don't see to have problems with other
packages I've tried.

Thanks,
Brian

Jack Tanner

unread,
Aug 25, 2010, 8:17:50 PM8/25/10
to rap...@googlegroups.com
The incantation I use is

gg = ggplot(...)
png(filename, type="cairo")
print(gg)
dev.off()

Perhaps that'll work for you.

bsteves

unread,
Aug 26, 2010, 11:59:52 AM8/26/10
to rapache
Thanks, printing the plot seems to do the job.
Reply all
Reply to author
Forward
0 new messages