[Tikzdevice-bugs] Font size in ggplot2 using tkzdevice

Cameron Bracken cameron.bracken at gmail.com
Fri Apr 30 01:28:08 CEST 2010


Lorenzo-

The dev version of tikzDevice hopefully contains a fix for this.  I
tried your example with it and the problem seems to be fixed (see the
attached pdf).  This version should be available on cran soon but you
can manually install it in the meantime.

-Cameron

--
Cameron Bracken
Graduate Research Assistant
Center for Advanced Decision Support for Water and Environmental Systems
University of Colorado at Boulder
cameron.bracken at colorado.edu
(707) 986-8633



On Thu, Apr 29, 2010 at 3:22 AM, Lorenzo Isella
<lorenzo.isella at gmail.com> wrote:
> Dear maintainers,
> I hope you will not mind my getting in touch with you.
> I am trying to find a way to tune font size (both in the axis title and in
> the legend) using ggplot2 and tikzDevice and I saw there has been already
> some activity in various forums about this issue e.g.
>
> http://bit.ly/baJXYe
>
> For reasons it would take long to explain, my pipeline is to produce a
> standalone tex file which is then compiled
> to generate the pdf (actually from within the .R file. Otherwise pdflatex
> test-new.tex would do).
> Please find below a self-contained example. If I look also at the generated
> tex file, it is clear that the font sizes are automatically set equal to 1,
> but I would like not to have to edit manually the tex file to get a pdf with
> the desired font size.
> Do you have any suggestions?
> Kind Regards
>
> Lorenzo
>
>
> ####################################################
> ####################################################
>
> library(ggplot2)
> library(Cairo)
> require(tikzDevice)
>
> ml_tmp <- as.data.frame(cbind(seq(10,2e4,length=100),seq(1e-6,1,length=100)
> ))
>
> names(ml_tmp) <- c("duration","p_contact")
>
>
> mb <- c(seq(10,100, by=10),
> seq(200,1e3,by=1e2),seq(2e3,1e4,by=1e3),seq(1e4,2e4,by=1e4))
>
> my_sel <- seq(1,length(mb), by=9)
>
> my_label2 <- rep("",length(mb))
> my_label2[my_sel] <- expression(10^1 ,10^2,10^3,10^4)
>
>
> mb3 <- c(seq(1e-6,1e-5, by=1e-6),
> seq(2e-5,1e-4,by=1e-5),seq(2e-4,1e-3,by=1e-4),seq(2e-3,1e-2,by=1e-3),
>       seq(2e-2,1e-1,by=1e-2),seq(2e-1,1,by=1e-1))
>
> my_sel <- seq(1,length(mb3), by=9)
>
> my_label3 <- rep("",length(mb3))
> my_label3[my_sel] <- expression(10^-6 ,10^-5,10^-4,10^-3,10^-2,10^-1,10^0)
>
>
>
> gpl <- ggplot(ml_tmp, aes(x=duration, y=p_contact)) +
> geom_point(size=1.5) +
>  opts( panel.background=theme_rect(fill='white'))+
> xlab(expression(paste("$l$")))+
> ylab(expression(paste("$M(l)$")))+
>  scale_x_continuous(trans="log10",
> limits=c(10,2e4),breaks=mb,label=my_label2)+
>  scale_y_continuous(trans="log10", limits=c(1e-6,1),
> breaks=mb3,label=my_label3)+
>  opts(plot.title = theme_text(size = 35))+
> opts(axis.title.x = theme_text(size = 35))+
> opts(legend.text = theme_text(size = 18, vjust=0.8))+
>  opts(legend.title = theme_text(size = 22,hjust=0))+
>  opts(panel.grid.minor = theme_blank())+
>  opts(axis.ticks = theme_segment(colour = "black",
> size=0.7),axis.ticks.length = unit(0.1, "cm"))+
> opts(panel.grid.major = theme_blank())+
> opts(legend.position = c(0.8, 0.6),
> legend.background=theme_rect(fill='white')
>     ,legend.key = theme_rect(colour = NA))+
> opts(axis.title.y = theme_text(size = 35, angle=90))+
> opts(axis.text.x = theme_text(size=30, colour="black",vjust=1))+
> opts(axis.text.y = theme_text(size=30, colour="black", hjust=1.1))
>
>
> ## fn <- paste("test-plot.pdf")
>
> ## pdf(fn)
> tikz('test-new.tex', standAlone = TRUE, width=5,height=5)
> print(gpl)
> dev.off()
>
> tools::texi2dvi('test-new.tex',pdf=T)
>
>
> _______________________________________________
> Tikzdevice-bugs mailing list
> Tikzdevice-bugs at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/tikzdevice-bugs
>


More information about the Tikzdevice-bugs mailing list