Respecting ggplot2 element_text font family

199 views
Skip to first unread message

Alastair Andrew

unread,
Aug 22, 2013, 7:54:29 AM8/22/13
to tikzd...@googlegroups.com
Hi,

Is there anyway to get RTikzDevice to use the same font face as you've
specified in family argument of element_text?

For example:

library(ggplot2)
p <- ggplot(diamonds, aes(carat, ..density..)) + geom_histogram(binwidth =
1)
p + facet_grid(. ~ cut) + theme(strip.text.x = element_text(family="mono"))

This example will have the facet labels typeset in a monospaced font. If I
use the tikzDevice the output will just have normal serif font face. Is
there anyway to achieve the look I want without manually wrapping the facet
labels in a LaTeX \texttt{}. I tend to find that approach leads to unusual
spacing issues. Especially in the legend.

Thanks,
Alastair.

Cameron Bracken

unread,
Aug 22, 2013, 1:14:58 PM8/22/13
to Alastair Andrew, tikzd...@googlegroups.com
At the moment, no. The problem is that tikzDevice doesn't respect par('family') which I assume is getting set for those text labels. We don't respect this because LaTeX has its own way of doing fonts. While "mono" may be something we can translate to a LaTeX command, other values of 'family' may not be. We would have to require that the value set for par('family') be an exact LaTeX font to avoid maintaining a map of 'family' values to LaTeX font names.  For the time being you will need to specify fonts in LaTeX. 

The spacing thing is another issue. If you have a specific example we can check it out, maybe there is a bug in the text placement somewhere. 

Cameron


_______________________________________________
Tikzdevice-bugs mailing list
Tikzdev...@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/tikzdevice-bugs

Reply all
Reply to author
Forward
0 new messages