How does tikz deal with raster images

25 views
Skip to first unread message

Martin Seilmayer

unread,
Jun 18, 2015, 2:52:15 AM6/18/15
to tikzd...@googlegroups.com
I have read, if tikz takes a raster image is to be stored as png. Having that tikz produces the rest of the graph around it and include the raster image back again.

Now I have the following:

pic <- T
if(pic)
{
  tikz
(file=paste(plotpath,"Rohdaten_S1_S2_D21.tex",sep=""),width=width,height=height,engine = "pdftex",)
 
#png(filename=paste(plotpath,"Rohdaten_S1_S2_D6.png",sep=""),width=width,height=height,res=res,units="in")
  par
(mfrow=c(2,1),mar=c(1.1,3,2,0),mgp=c(1.5,0.5,0),ps=f.size,cex=1,xaxt="n")
}
if(!pic) par(mfrow=c(2,1),mar=c(1,4,3,0))
for(i in 1:2)
{
  x
<- sensors[[i]]$time
  y
<- sensors[[i]]$depth
  z
<- sensors[[i]]$velo
  image
(x,y,z)
 
#   plot.image(x,y,z
#              ,xlim=c(max(x)-400,max(x)),zlim=2*c(-1,1)
#              ,xlab="",ylab="$d/\\mathrm{m}$",zlab="$v/(\\mathrm{mm/s})$"
#              ,z.adj=c(0,0),ndz=5,z.cex=1
#              )  
  abline
(v=(1:10)/0.026+par("usr")[1],lty=2)
 
if(!pic) abline(h=(1:floor(max(y/0.02)))*0.02)
  mtext
(text=paste("Sensor",i),side=3,line=0.1,adj=0)
  par
(mar=c(3,3,0.1,0),xaxt="s")
}
title
(xlab="t/s")
if(pic) dev.off()

even the simple image() function will produce a 100MB large .tex file.
No png is produced, everything is in the .tex file?!

What am I doing wrong? Is there a switch to be set TRUE?


Thank you for your help.

kirill...@gmail.com

unread,
Nov 18, 2015, 3:42:19 AM11/18/15
to tikzdevice
Sorry for my slow reply. 

kirill...@gmail.com

unread,
Nov 18, 2015, 3:44:51 AM11/18/15
to tikzdevice
I don't know how plot.image() works internally, but if it instructs the graphics driver to paint thousands of filled squares, this is what the graphics driver does -- and in the case of tikzDevice this results in a huge file.

I don't remember such issues with ggplot2/grid graphics, so you may want to try an alternative method of producing the plots.


-Kirill


On Thursday, June 18, 2015 at 8:52:15 AM UTC+2, Martin Seilmayer wrote:
Reply all
Reply to author
Forward
0 new messages