Respecting ggplot2 element_text font family

瀏覽次數:199 次
跳到第一則未讀訊息

Alastair Andrew

未讀,
2013年8月22日 清晨7:54:292013/8/22
收件者: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

未讀,
2013年8月22日 下午1:14:582013/8/22
收件者: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

回覆所有人
回覆作者
轉寄
0 則新訊息