Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems with ggplot and pgfSweave
    primarykey
    data
    text
    <p>I started using Sweave some time ago. However, like most people I encountered pretty soon a major problem: Speed. Sweaving a large document takes ages to run, which makes efficient working quite challenging. Data processing can be accelerated very much with cacheSweave. However, plots - especially ggplot ;) - still take too long to render. That’s way I want to use pgfSweave.</p> <p>After many, many hours, I finally succeeded in setting up a working system with Eclipse/StatET/Texlipse. I then wanted to convert an existing report to use with pgfSweave and had a bad surprise: most of my ggplots doesn’t seem to work anymore. The following plot for example works perfectly in the console and Sweave:</p> <pre><code>pl &lt;- ggplot(plot_info,aes(elevation,area)) pl &lt;- pl + geom_point(aes(colour=que_id)) print(pl) </code></pre> <p>Running it with pgfSweave, however, I get this error:</p> <pre><code>Error in if (width &gt; 0) { : missing value where TRUE/FALSE needed In addition: Warning message: In if (width &gt; 0) { : the condition has length &gt; 1 and only the first element will be used Error in driver$runcode(drobj, chunk, chunkopts) : Error in if (width &gt; 0) { : missing value where TRUE/FALSE needed </code></pre> <p>When I remove aes(...) from geom_point, the plot works perfectly with pgfSweave.</p> <pre><code>pl &lt;- ggplot(plot_info,aes(elevation,area)) pl &lt;- pl + geom_point() print(pl) </code></pre> <p>Edit: I investigated more into the problem and could reduce the problem to the tikz-device.</p> <p>This works just fine:</p> <pre><code>quartz() pl &lt;- ggplot(plot_info,aes(elevation,area)) pl &lt;- pl + geom_point(aes(colour=que_id)) print(pl) </code></pre> <p>This gives the above error:</p> <pre><code>tikz( 'myPlot.tex',standAlone = T ) pl &lt;- ggplot(plot_info,aes(elevation,area)) pl &lt;- pl + geom_point(aes(colour=que_id)) print(pl) dev.off() </code></pre> <p>This works just fine as well:</p> <pre><code>tikz( 'myPlot.tex',standAlone = T ) pl &lt;- ggplot(plot_info,aes(elevation,area)) pl &lt;- pl + geom_point() print(pl) dev.off() </code></pre> <p>I could repeat this with 5 different ggplots. When not using colour (or size, alpha,...) in the mapping, it works with tikz.</p> <p>Q1: Does anybody has any explanations for this behavior? </p> <p>Additionally, caching of non-plot code chunks doesn’t work very well. The following code chunk takes no time at all with Sweave. With pgfSweave, it takes approximately 10 sec.</p> <pre><code>&lt;&lt;plot.opts,echo=FALSE,results=hide,cache=TRUE&gt;&gt;= #colour and plot options are globally set pal1 &lt;- brewer.pal(8,"Set1") pal_seq &lt;- brewer.pal(8,"YlOrRd") pal_seq &lt;- c("steelblue1","tomato2") opt1 &lt;- opts(panel.grid.major = theme_line(colour = "white"),panel.grid.minor = theme_line(colour = "white")) sca_fill_cont_opt &lt;- scale_fill_continuous(low="steelblue1", high="tomato2") ory &lt;- geom_hline(yintercept=0,alpha=0.4,linetype=2) orx &lt;- geom_vline(xintercept=0,alpha=0.4,linetype=2) ts1 &lt;- 2.3 ts2 &lt;- 2.5 ts3 &lt;- 2.8 ps1 &lt;- 6 offset_x &lt;- function(x,y) 0.15*x/pmax(abs(x),abs(y)) offset_y &lt;- function(x,y) 0.05*y/pmax(abs(x),abs(y)) plot_size &lt;- 50*50 </code></pre> <p>This seems a pretty strange behavior as well, as only some variables are set for later use.</p> <p>Q2: Anybody got any explanations for that?</p> <p>Q3: More generally, I would like to ask if anybody at all is using pgfSweave successfully? With successfully I mean that all things that work in Sweave also work in pgfSweave, with the additional benefit of nice fonts and improved speed. ;)</p> <p>Thanks very much for responses!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload