[Tikzdevice-bugs] ggplot-tikz examples

Felipe Carrillo mazatlanmexico at yahoo.com
Thu Jul 28 23:17:38 CEST 2011


Cameron:
I have actually been reading the manual and is making a little more sense now. Yes, I am familiar with LaTex and
I have been creating my pdf's with sweave and then texi2dvi for my tex file creating nice reports with graphics and tables.
I am able to run the code below sucessfully creating the pdf but I haven't figure out how to create a table or how to write the
text such introduction, abstract etc. 
 
library(tikzDevice)
# Minimal plot
tikz('example1.tex',standAlone=TRUE)
#plot(1)
d <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
  xlim(0, 2) + stat_binhex(na.rm = TRUE) + opts(aspect.ratio = 1)
d + facet_wrap(~ color)
dev.off()
CAN I INSERT A PARAGRAPH HERE?
plot(1)  create another graph
THEN INSERT A TABLE HERE?
# View the output
tools::texi2dvi('example1.tex',pdf=T)
system(paste(getOption('pdfviewer'),'example1.pdf'))
 
 Or I have to create a normal rnw file in order to input text and tables?
 

Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA
http://www.fws.gov/redbluff/rbdd_jsmp.aspx


From: Cameron Bracken <cameron.bracken at gmail.com>
>To: Felipe Carrillo <mazatlanmexico at yahoo.com>
>Cc: "tikzdevice at googlegroups.com" <tikzdevice at googlegroups.com>; tikzDevice Bugs <tikzdevice-bugs at r-forge.wu-wien.ac.at>
>Sent: Thursday, July 28, 2011 12:53 PM
>Subject: Re: [Tikzdevice-bugs] ggplot-tikz examples
>
>Felipe-
>
>On Jul 27, 2011, at 8:42 PM, Felipe Carrillo wrote:
>
>> Hi:
>> I am using my laptop from home and everything seems to work ok here. A couple of
>> question if you don't mind:
>> 1 - If I want to create say a 20 page report with graphics
>> and tables do I use the tikz() function over and over to make the graphics and tables or just one
>> time at the beginning of my script?
>>  
>
>The short answer to your first question is you would have to invoke the tikz() command for every graphic you want to create and then \input it into you document:
>
>\documentclass{article}
>\usepackage{tikz}
>\begin{document}
>\begin{figure}
>\centering
>\input{Rplots.tex}
>\caption{}
>\end{figure}
>\end{document}
>
>But this sounds like a perfect use for pgfSweave. It will invoke tikz() for you and include the results in the correct way without you having to worry about the details (I assume you are already familiar with Sweave). There are a few examples to get you started here:
>
>https://github.com/cameronbracken/pgfSweave/tree/master/inst/example
>
>There are some other great benefits of using pgfSweave such as caching of computations and graphics. I suggest checking out the vignette once the package is installed:
>
>vignette('pgfSweave')
>
>> 2- How do I include other LaTex packages using for example \usepackage{geometry}
>>  
>> I will check the manual but I would appreciate it if you can point out to a tex file or a latex document
>> created with tikzDevice.
>>  
>
>To answer your second question, you can add necessary packages with the tikzDevice options:
>
>options(tikzLatexPackages = c(getOption('tikzLatexPackages'),'\\usepackage{geometry}\n'))
>
>see ?tikDevice for more options. These packages are used when calculating the character metrics from LaTeX along with those in the tikzMetricPackages option. If you don't need the geometry package for that then you can just include it in the document header where the graphic is \input. 
>
>-Cameron
>
>>  
>> Felipe D. Carrillo
>> Supervisory Fishery Biologist
>> Department of the Interior
>> US Fish & Wildlife Service
>> California, USA
>> http://www.fws.gov/redbluff/rbdd_jsmp.aspx
>> 
>> From: Charlie Sharpsteen <chuck at sharpsteen.net>
>> To: tikzdevice at googlegroups.com
>> Cc: Cameron Bracken <cameron.bracken at gmail.com>; tikzDevice Bugs <tikzdevice-bugs at r-forge.wu-wien.ac.at>; Felipe Carrillo <mazatlanmexico at yahoo.com>
>> Sent: Wednesday, July 27, 2011 1:37 PM
>> Subject: Re: [Tikzdevice-bugs] ggplot-tikz examples
>> 
>> On Wednesday, July 27, 2011 1:30:26 PM UTC-7, Felipe Carrillo wrote:
>> I don't know if I have PGF or the preview package,,I think I only have MiKTex
>> Where can I get the above-mentioned package and software?
>> 
>> The MiKTeX package manager can help you install LaTeX packages. To do so, execute the following in a command line shell (cmd.exe):
>> 
>>    mpm --install pgf
>>    mpm --install preview 
>> 
>> 
>> On Wednesday, July 27, 2011 1:26:59 PM UTC-7, Felipe Carrillo wrote:
>> Hi Cameron, Charlie:
>> I am guessing that this file isn't created as stated below because I am using a goverment computer
>> right now and some of the drives are write protected. If you think this could be the cause of the error
>> message, I will run this at home tonight and see what happens. Thanks for the awesome package.
>>  
>> Creating temporary TikZ metrics dictionary at:
>>        C:\DOCUME~1\FCARRI~1\LOCALS~1\ Temp\Rtmpd7Mnxe/ tikzMetricsDictionary
>> 
>> That could be the problem. However, it looks like R is able to write the temporary files that are used to calculate metrics and the temporary metrics dictionary is also created in the same location.
>> 
>> -Charlie 
>> 
>> 
>
>
>
>


More information about the Tikzdevice-bugs mailing list